--- /dev/null
+Makefile.in
+aclocal.m4
+build-stamp
+config.guess
+config.h.in
+config.sub
+configure
+debian/files
+debian/tmp
+debian/*.debhelper.log
+debian/*.substvars
+debian/xserver-xorg-video-sec/
+depcomp
+install-sh
+ltmain.sh
+missing
+/obj-i486-linux-gnu/
+/obj-arm-linux-gnueabi/
+stampdir
+/autom4te.cache/
+/debian/xserver-xorg-video-emulfb-dbg/
+/debian/xserver-xorg-video-emulfb/
--- /dev/null
+SooChan Lim <sc1.lim@samsung.com>
+SangJin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>
--- /dev/null
+Copyright (C) 2010 - 2011 Samsung Electronics co., Ltd. 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 fur-
+nished 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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+
--- /dev/null
+2010-08-30 SooChan Lim <sc1.lim@samsung.com>
+
+ Initial version of xserver-xorg-video-emulfb
+
+
--- /dev/null
+# 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.
+
+AUTOMAKE_OPTIONS = foreign
+SUBDIRS = src man
--- /dev/null
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+#$srcdir/configure --enable-maintainer-mode "$@"
--- /dev/null
+
+AC_PREREQ(2.57)
+AC_INIT([xserver-xorg-video-emulfb],
+ 0.1.0,
+ [https://],
+ xserver-xorg-video-emulfb)
+
+AC_CONFIG_SRCDIR([Makefile.am])
+AM_CONFIG_HEADER([config.h])
+AC_CONFIG_AUX_DIR(.)
+
+AM_INIT_AUTOMAKE([dist-bzip2])
+
+AM_MAINTAINER_MODE
+
+# Checks for programs.
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+AC_PROG_CC
+AM_PROG_AS
+
+AH_TOP([#include "xorg-server.h"])
+
+AC_ARG_WITH(xorg-module-dir,
+ AC_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+AC_ARG_ENABLE(pciaccess,
+ AS_HELP_STRING([--enable-pciaccess],
+ [Enable use of libpciaccess (default: disabled)]),
+ [PCIACCESS=$enableval], [PCIACCESS=no])
+
+AC_ARG_ENABLE(v4l2,
+ AS_HELP_STRING([--enable-v4l2],
+ [Enable v4l2 (default: enabled)]),
+ [V4L2=$enableval], [V4L2=yes])
+
+# Checks for extensions
+XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+XORG_DRIVER_CHECK_EXT(XV, videoproto)
+
+# Checks for pkg-config packages
+PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
+sdkdir=$(pkg-config --variable=sdkdir xorg-server)
+
+# check the conditions
+EMULFB_CFALGS=""
+EMULFB_LIBS=""
+
+PKG_CHECK_MODULES(DLOG, dlog)
+PKG_CHECK_MODULES(DRM, libdrm)
+PKG_CHECK_MODULES(PIXMAN, pixman-1)
+
+EMULFB_CFLAGS="$EMULFB_CFLAGS $DLOG_CFLAGS $PIXMAN_CFLAGS $DRM_CFLAGS "
+EMULFB_LIBS="$EMULFB_LIBS $DLOG_LIBS $PIXMAN_LIBS $DRM_LIBS "
+
+AM_CONDITIONAL(V4L2, test "x$V4L2" = xyes)
+if test "x$V4L2" = xyes; then
+ AC_DEFINE(ENABLE_V4L2, 1, [Enable v4l2])
+fi
+
+AM_CONDITIONAL(PCIACCESS, [test "x$PCIACCESS" = xyes])
+if test "x$PCIACCESS" = xyes; then
+ AC_DEFINE(PCIACCESS, 1, [Use libpciaccess])
+ PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+ XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS "
+fi
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDC
+
+AC_SUBST([EMULFB_CFLAGS])
+AC_SUBST([EMULFB_LIBS])
+
+AC_SUBST([XORG_CFLAGS])
+AC_SUBST([moduledir])
+
+DRIVER_NAME=emulfb
+AC_SUBST([DRIVER_NAME])
+
+XORG_MANPAGE_SECTIONS
+XORG_RELEASE_VERSION
+
+AC_OUTPUT([
+ Makefile
+ src/Makefile
+ man/Makefile
+])
--- /dev/null
+xserver-xorg-video-emulfb (1:1.0.0-2) unstable; urgency=low
+
+ * change driver name
+ * Git: slp/pkgs/xorg/driver/xserver-xorg-video-emulfb
+ * Tag: xserver-xorg-video-emulfb_1.0.0-2
+
+ -- Boram Park <boram1288.park@samsung.com> Thu, 22 Dec 2011 13:47:29 +0900
+
+xserver-xorg-video-emulfb (1:1.0.0-1) unstable; urgency=low
+
+ * Init
+
+ -- Boram Park <boram1288.park@samsung.com> Wed, 14 Dec 2011 14:41:00 +0900
--- /dev/null
+Source: xserver-xorg-video-emulfb
+Section: x11
+Priority: optional
+Maintainer: SooChan Lim <sc1.lim@samsung.com>
+Uploaders: Sung-Jin Park <sj76.park@samsung.com>, SooChan Lim <sc1.lim@samsung.com>, YoungHoon Jung <yhoon.jung@samsung.com>, Sangjin Lee <lsj119@samsung.com>, Boram Park <boram1288.park@samsung.com>
+Build-Depends: debhelper (>= 5.0.0), quilt, pkg-config, xserver-xorg-dev (>= 1.5.99.901), x11proto-core-dev, x11proto-fonts-dev, x11proto-randr-dev, x11proto-render-dev, x11proto-video-dev, dpkg-dev (>= 1.14.17), automake, libtool, xutils-dev, libdrm-dev, dlog-dev (>= 0.3.3-0), libpixman-1-dev
+Standards-Version: 3.7.3
+
+Package: xserver-xorg-video-emulfb
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${xserver}
+Provides: ${xviddriver:Provides}
+Replaces: xserver-xorg (<< 6.8.2-35)
+Description: X.Org X server -- emulfb display driver for sdk emulation
+ This package provides the driver for the Samsung display device
+
+Package: xserver-xorg-video-emulfb-dbg
+Architecture: any
+Section: debug
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${xserver}, xserver-xorg-video-emulfb
+Description: X.Org X server -- emulfb display driver for sdk emulation (unstripped)
+ This package provides the driver for the Samsung display device
--- /dev/null
+Copyright (C) 2010 - 2011 Samsung Electronics co., Ltd. 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 fur-
+nished 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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+
--- /dev/null
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+include debian/xsfbs/xsfbs.mk
+
+CFLAGS = -Wall -Werror -g
+LDFLAGS += -Wl,--hash-style=both -Wl,--as-needed
+ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+ NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+ MAKEFLAGS += -j$(NUMJOBS)
+endif
+
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+ confflags += --build=$(DEB_HOST_GNU_TYPE)
+else
+ confflags += --build=$(DEB_HOST_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+# confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+endif
+
+ifeq (armel, $(DEB_HOST_ARCH))
+ confflags += --disable-v4l2
+endif
+
+# kbd_drv.a isn't phenomenally useful; kbd_drv.so more so
+confflags += --disable-static
+
+configure: $(STAMP_DIR)/patch
+ dh_testdir
+ autoreconf -vfi
+
+build: build-stamp
+build-stamp: configure
+ dh_testdir
+
+ test -d obj-$(DEB_BUILD_GNU_TYPE) || mkdir obj-$(DEB_BUILD_GNU_TYPE)
+ cd obj-$(DEB_BUILD_GNU_TYPE) && \
+ ../configure --prefix=/usr --mandir=\$${prefix}/share/man \
+ --infodir=\$${prefix}/share/info $(confflags) \
+ CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
+ cd obj-$(DEB_BUILD_GNU_TYPE) && $(MAKE)
+ >$@
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ cd obj-$(DEB_BUILD_GNU_TYPE) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+# Build architecture-dependent files here.
+binary: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installchangelogs ChangeLog
+ dh_install --sourcedir=debian/tmp --list-missing
+ dh_link
+ dh_strip --dbg-package=xserver-xorg-video-emulfb-dbg
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps --
+ #dh_shlibdeps -- --warnings=6
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+
+
+clean: xsfclean
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ rm -f config.cache config.log config.status
+ rm -f */config.cache */config.log */config.status
+ rm -f conftest* */conftest*
+ rm -rf autom4te.cache */autom4te.cache
+ rm -rf obj-*
+ rm -f aclocal.m4 config.guess config.sub config.h.in configure
+ rm -f depcomp install-sh ltmain.sh missing mkinstalldirs
+ rm -f $$(find -name Makefile.in)
+ rm -f build-stamp-*
+ dh_clean
+
+
+binary-arch: binary
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- /dev/null
+usr/lib/xorg/modules/drivers/*.so
+usr/share/man/man4/*
--- /dev/null
+usr/share/bug/xserver-xorg-core/script usr/share/bug/xserver-xorg-video-emulfb/script
--- /dev/null
+#!/bin/sh
+
+set -e
+
+if ! [ -d debian/prune ]; then
+ exit 0
+fi
+
+if [ "x$1" != x--upstream-version ]; then
+ exit 1
+fi
+
+version="$2"
+filename="$3"
+
+if [ -z "$version" ] || ! [ -f "$filename" ]; then
+ exit 1
+fi
+
+dir="$(pwd)"
+tempdir="$(mktemp -d)"
+
+cd "$tempdir"
+tar xf "$dir/$filename"
+cat "$dir"/debian/prune/* | while read file; do rm -f */$file; done
+
+tar czf "$dir/$filename" *
+cd "$dir"
+rm -rf "$tempdir"
+echo "Done pruning upstream tarball"
+
+exit 0
--- /dev/null
+#!/usr/bin/make -f
+
+# Debian X Strike Force Build System (XSFBS): Make portion
+
+# Copyright 1996 Stephen Early
+# Copyright 1997 Mark Eichin
+# Copyright 1998-2005, 2007 Branden Robinson
+# Copyright 2005 David Nusinow
+#
+# Licensed under the GNU General Public License, version 2. See the file
+# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
+
+# Originally by Stephen Early <sde1000@debian.org>
+# Modified by Mark W. Eichin <eichin@kitten.gen.ma.us>
+# Modified by Adam Heath <doogie@debian.org>
+# Modified by Branden Robinson <branden@debian.org>
+# Modified by Fabio Massimo Di Nitto <fabbione@fabbione.net>
+# Modified by David Nusinow <dnusinow@debian.org>
+# Acknowledgements to Manoj Srivastava.
+
+# Pass $(DH_OPTIONS) into the environment for debhelper's benefit.
+export DH_OPTIONS
+
+# force quilt to not use ~/.quiltrc and to use debian/patches
+QUILT = QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null
+
+# Set up parameters for the upstream build environment.
+
+# Determine (source) package name from Debian changelog.
+SOURCE_NAME:=$(shell dpkg-parsechangelog -ldebian/changelog \
+ | grep '^Source:' | awk '{print $$2}')
+
+# Determine package version from Debian changelog.
+SOURCE_VERSION:=$(shell dpkg-parsechangelog -ldebian/changelog \
+ | grep '^Version:' | awk '{print $$2}')
+
+# Determine upstream version number.
+UPSTREAM_VERSION:=$(shell echo $(SOURCE_VERSION) | sed 's/-.*//')
+
+# Determine the source version without the epoch for make-orig-tar-gz
+NO_EPOCH_VER:=$(shell echo $(UPSTREAM_VERSION) | sed 's/^.://')
+
+# Figure out who's building this package.
+BUILDER:=$(shell echo $${DEBEMAIL:-$${EMAIL:-$$(echo $$LOGNAME@$$(cat /etc/mailname 2>/dev/null))}})
+
+# Find out if this is an official build; an official build has nothing but
+# digits, dots, and/or the codename of a release in the Debian part of the
+# version number. Anything else indicates an unofficial build.
+OFFICIAL_BUILD:=$(shell VERSION=$(SOURCE_VERSION); if ! expr "$$(echo $${VERSION\#\#*-} | sed 's/\(woody\|sarge\|etch\|lenny\)//g')" : ".*[^0-9.].*" >/dev/null 2>&1; then echo yes; fi)
+
+# Set up parameters for the Debian build environment.
+
+# Determine our architecture.
+BUILD_ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
+# Work around some old-time dpkg braindamage.
+BUILD_ARCH:=$(subst i486,i386,$(BUILD_ARCH))
+# The DEB_HOST_ARCH variable may be set per the Debian cross-compilation policy.
+ifdef DEB_HOST_ARCH
+ ARCH:=$(DEB_HOST_ARCH)
+else
+ # dpkg-cross sets the ARCH environment variable; if set, use it.
+ ifdef ARCH
+ ARCH:=$(ARCH)
+ else
+ ARCH:=$(BUILD_ARCH)
+ endif
+endif
+
+# $(STAMP_DIR) houses stamp files for complex targets.
+STAMP_DIR:=stampdir
+
+# $(DEBTREEDIR) is where all install rules are told (via $(DESTDIR)) to place
+# their files.
+DEBTREEDIR:=$(CURDIR)/debian/tmp
+
+# All "important" targets have four lines:
+# 1) A target name that is invoked by a package-building tool or the user.
+# This consists of a dependency on a "$(STAMP_DIR)/"-prefixed counterpart.
+# 2) A line delcaring 1) as a phony target (".PHONY:").
+# 3) A "$(STAMP_DIR)/"-prefixed target which does the actual work, and may
+# depend on other targets.
+# 4) A line declaring 3) as a member of the $(stampdir_targets) variable; the
+# "$(STAMP_DIR)/" prefix is omitted.
+#
+# This indirection is needed so that the "stamp" files that signify when a rule
+# is done can be located in a separate "stampdir". Recall that make has no way
+# to know when a goal has been met for a phony target (like "build" or
+# "install").
+#
+# At the end of each "$(STAMP_DIR)/" target, be sure to run the command ">$@"
+# so that the target will not be run again. Removing the file will make Make
+# run the target over.
+
+# All phony targets should be declared as dependencies of .PHONY, even if they
+# do not have "($STAMP_DIR)/"-prefixed counterparts.
+
+# Define a harmless default rule to keep things from going nuts by accident.
+.PHONY: default
+default:
+
+# Set up the $(STAMP_DIR) directory.
+.PHONY: stampdir
+stampdir_targets+=stampdir
+stampdir: $(STAMP_DIR)/stampdir
+$(STAMP_DIR)/stampdir:
+ mkdir $(STAMP_DIR)
+ >$@
+
+# Set up the package build directory as quilt expects to find it.
+.PHONY: prepare
+stampdir_targets+=prepare
+prepare: $(STAMP_DIR)/prepare
+$(STAMP_DIR)/prepare: $(STAMP_DIR)/log $(STAMP_DIR)/genscripts
+ >$@
+
+.PHONY: log
+stampdir_targets+=log
+log: $(STAMP_DIR)/log
+$(STAMP_DIR)/log: $(STAMP_DIR)/stampdir
+ mkdir -p $(STAMP_DIR)/log
+
+# Apply all patches to the upstream source.
+.PHONY: patch
+stampdir_targets+=patch
+patch: $(STAMP_DIR)/patch
+$(STAMP_DIR)/patch: $(STAMP_DIR)/prepare
+ if ! [ `which quilt` ]; then \
+ echo "Couldn't find quilt. Please install it or add it to the build-depends for this package."; \
+ exit 1; \
+ fi; \
+ if $(QUILT) next >/dev/null 2>&1; then \
+ echo -n "Applying patches..."; \
+ if $(QUILT) push -a -v >$(STAMP_DIR)/log/patch 2>&1; then \
+ cat $(STAMP_DIR)/log/patch; \
+ echo "successful."; \
+ else \
+ cat $(STAMP_DIR)/log/patch; \
+ echo "failed! (check $(STAMP_DIR)/log/patch for details)"; \
+ exit 1; \
+ fi; \
+ else \
+ echo "No patches to apply"; \
+ fi; \
+ >$@
+
+# Revert all patches to the upstream source.
+.PHONY: unpatch
+unpatch: $(STAMP_DIR)/log
+ rm -f $(STAMP_DIR)/patch
+ @echo -n "Unapplying patches..."; \
+ if $(QUILT) applied >/dev/null 2>/dev/null; then \
+ if $(QUILT) pop -a -v >$(STAMP_DIR)/log/unpatch 2>&1; then \
+ cat $(STAMP_DIR)/log/unpatch; \
+ echo "successful."; \
+ else \
+ cat $(STAMP_DIR)/log/unpatch; \
+ echo "failed! (check $(STAMP_DIR)/log/unpatch for details)"; \
+ exit 1; \
+ fi; \
+ else \
+ echo "nothing to do."; \
+ fi
+
+# Clean the generated maintainer scripts.
+.PHONY: cleanscripts
+cleanscripts:
+ rm -f $(STAMP_DIR)/genscripts
+ rm -f debian/*.config \
+ debian/*.postinst \
+ debian/*.postrm \
+ debian/*.preinst \
+ debian/*.prerm
+
+# Clean the package build tree.
+.PHONY: xsfclean
+xsfclean: cleanscripts unpatch
+ dh_testdir
+ rm -rf .pc
+ rm -rf $(STAMP_DIR) $(SOURCE_DIR)
+ rm -rf imports
+ dh_clean debian/shlibs.local \
+ debian/po/pothead
+
+# Generate the debconf templates POT file header.
+debian/po/pothead: debian/po/pothead.in
+ sed -e 's/SOURCE_VERSION/$(SOURCE_VERSION)/' \
+ -e 's/DATE/$(shell date "+%F %X%z"/)' <$< >$@
+
+# Update POT and PO files.
+.PHONY: updatepo
+updatepo: debian/po/pothead
+ debian/scripts/debconf-updatepo --pot-header=pothead --verbose
+
+# Remove files from the upstream source tree that we don't need, or which have
+# licensing problems. It must be run before creating the .orig.tar.gz.
+#
+# Note: This rule is for Debian package maintainers' convenience, and is not
+# needed for conventional build scenarios.
+.PHONY: prune-upstream-tree
+prune-upstream-tree:
+ # Ensure we're in the correct directory.
+ dh_testdir
+ grep -rvh '^#' debian/prune/ | xargs --no-run-if-empty rm -rf
+
+# Verify that there are no offsets or fuzz in the patches we apply.
+#
+# Note: This rule is for Debian package maintainers' convenience, and is not
+# needed for conventional build scenarios.
+.PHONY: patch-audit
+patch-audit: prepare unpatch
+ @echo -n "Auditing patches..."; \
+ >$(STAMP_DIR)/log/patch; \
+ FUZZY=; \
+ while [ -n "$$($(QUILT) next)" ]; do \
+ RESULT=$$($(QUILT) push -v | tee -a $(STAMP_DIR)/log/patch | grep ^Hunk | sed 's/^Hunk.*\(succeeded\|FAILED\).*/\1/');\
+ case "$$RESULT" in \
+ succeeded) \
+ echo "fuzzy patch: $$($(QUILT) top)" \
+ | tee -a $(STAMP_DIR)/log/$$($(QUILT) top); \
+ FUZZY=yes; \
+ ;; \
+ FAILED) \
+ echo "broken patch: $$($(QUILT) next)" \
+ | tee -a $(STAMP_DIR)/log/$$($(QUILT) next); \
+ exit 1; \
+ ;; \
+ esac; \
+ done; \
+ if [ -n "$$FUZZY" ]; then \
+ echo "there were fuzzy patches; please fix."; \
+ exit 1; \
+ else \
+ echo "done."; \
+ fi
+
+# Generate the maintainer scripts.
+.PHONY: genscripts
+stampdir_targets+=genscripts
+genscripts: $(STAMP_DIR)/genscripts
+$(STAMP_DIR)/genscripts: $(STAMP_DIR)/stampdir
+ for FILE in debian/*.config.in \
+ debian/*.postinst.in \
+ debian/*.postrm.in \
+ debian/*.preinst.in \
+ debian/*.prerm.in; do \
+ if [ -e "$$FILE" ]; then \
+ MAINTSCRIPT=$$(echo $$FILE | sed 's/.in$$//'); \
+ sed -n '1,/^#INCLUDE_SHELL_LIB#$$/p' <$$FILE \
+ | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >$$MAINTSCRIPT.tmp; \
+ cat debian/xsfbs/xsfbs.sh >>$$MAINTSCRIPT.tmp; \
+ sed -n '/^#INCLUDE_SHELL_LIB#$$/,$$p' <$$FILE \
+ | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >>$$MAINTSCRIPT.tmp; \
+ sed -e 's/@SOURCE_VERSION@/$(SOURCE_VERSION)/' \
+ -e 's/@OFFICIAL_BUILD@/$(OFFICIAL_BUILD)/' \
+ -e 's/@DEFAULT_DCRESOLUTIONS@/$(DEFAULT_DCRESOLUTIONS)/' \
+ <$$MAINTSCRIPT.tmp >$$MAINTSCRIPT; \
+ rm $$MAINTSCRIPT.tmp; \
+ fi; \
+ done
+ # Validate syntax of generated shell scripts.
+ #sh debian/scripts/validate-posix-sh debian/*.config \
+ # debian/*.postinst \
+ # debian/*.postrm \
+ # debian/*.preinst \
+ # debian/*.prerm
+ >$@
+
+# Generate the shlibs.local file.
+debian/shlibs.local:
+ cat debian/*.shlibs >$@
+
+SERVERMINVERS = $(shell cat /usr/share/xserver-xorg/serverminver 2>/dev/null)
+VIDEOABI = $(shell cat /usr/share/xserver-xorg/videoabiver 2>/dev/null)
+INPUTABI = $(shell cat /usr/share/xserver-xorg/inputabiver 2>/dev/null)
+SERVER_DEPENDS = xserver-xorg-core (>= $(SERVERMINVERS))
+VIDDRIVER_PROVIDES = xserver-xorg-video-$(VIDEOABI)
+INPDRIVER_PROVIDES = xserver-xorg-input-$(INPUTABI)
+ifeq ($(PACKAGE),)
+PACKAGE=$(shell awk '/^Package:/ { print $$2; exit }' < debian/control)
+endif
+
+.PHONY: serverabi
+serverabi: install
+ifeq ($(SERVERMINVERS),)
+ @echo error: xserver-xorg-dev needs to be installed
+ @exit 1
+else
+ echo "xserver:Depends=$(SERVER_DEPENDS)" >> debian/$(PACKAGE).substvars
+ echo "xviddriver:Provides=$(VIDDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
+ echo "xinpdriver:Provides=$(INPDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
+endif
+
+# vim:set noet ai sts=8 sw=8 tw=0:
--- /dev/null
+# $Id$
+
+# This is the X Strike Force shell library for X Window System package
+# maintainer scripts. It serves to define shell functions commonly used by
+# such packages, and performs some error checking necessary for proper operation
+# of those functions. By itself, it does not "do" much; the maintainer scripts
+# invoke the functions defined here to accomplish package installation and
+# removal tasks.
+
+# If you are reading this within a Debian package maintainer script (e.g.,
+# /var/lib/dpkg)info/PACKAGE.{config,preinst,postinst,prerm,postrm}), you can
+# skip past this library by scanning forward in this file to the string
+# "GOBSTOPPER".
+
+SOURCE_VERSION=@SOURCE_VERSION@
+OFFICIAL_BUILD=@OFFICIAL_BUILD@
+
+# Use special abnormal exit codes so that problems with this library are more
+# easily tracked down.
+SHELL_LIB_INTERNAL_ERROR=86
+SHELL_LIB_THROWN_ERROR=74
+SHELL_LIB_USAGE_ERROR=99
+
+# old -> new variable names
+if [ -z "$DEBUG_XORG_PACKAGE" ] && [ -n "$DEBUG_XFREE86_PACKAGE" ]; then
+ DEBUG_XORG_PACKAGE="$DEBUG_XFREE86_PACKAGE"
+fi
+if [ -z "$DEBUG_XORG_DEBCONF" ] && [ -n "$DEBUG_XFREE86_DEBCONF" ]; then
+ DEBUG_XORG_DEBCONF="$DEBUG_XFREE86_DEBCONF"
+fi
+
+# initial sanity checks
+if [ -z "$THIS_PACKAGE" ]; then
+ cat >&2 <<EOF
+Error: package maintainer script attempted to use shell library without
+definining \$THIS_PACKAGE shell variable. Please report the package name,
+version, and the text of this error message to the Debian Bug Tracking System.
+Visit <http://www.debian.org/Bugs/Reporting> on the World Wide Web for
+instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the
+"doc-debian" package, or install the "reportbug" package and use the command of
+the same name to file a report against version $SOURCE_VERSION of this package.
+EOF
+ exit $SHELL_LIB_USAGE_ERROR
+fi
+
+if [ -z "$THIS_SCRIPT" ]; then
+ cat >&2 <<EOF
+Error: package maintainer script attempted to use shell library without
+definining \$THIS_SCRIPT shell variable. Please report the package name,
+version, and the text of this error message to the Debian Bug Tracking System.
+Visit <http://www.debian.org/Bugs/Reporting> on the World Wide Web for
+instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the
+"doc-debian" package, or install the "reportbug" package and use the command of
+the same name to file a report against version $SOURCE_VERSION of the
+"$THIS_PACKAGE" package.
+EOF
+ exit $SHELL_LIB_USAGE_ERROR
+fi
+
+ARCHITECTURE="$(dpkg --print-installation-architecture)"
+
+if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
+ RECONFIGURE="true"
+else
+ RECONFIGURE=
+fi
+
+if ([ "$1" = "install" ] || [ "$1" = "configure" ]) && [ -z "$2" ]; then
+ FIRSTINST="yes"
+fi
+
+if [ -z "$RECONFIGURE" ] && [ -z "$FIRSTINST" ]; then
+ UPGRADE="yes"
+fi
+
+trap "message;\
+ message \"Received signal. Aborting $THIS_PACKAGE package $THIS_SCRIPT script.\";\
+ message;\
+ exit 1" HUP INT QUIT TERM
+
+reject_nondigits () {
+ # syntax: reject_nondigits [ operand ... ]
+ #
+ # scan operands (typically shell variables whose values cannot be trusted) for
+ # characters other than decimal digits and barf if any are found
+ while [ -n "$1" ]; do
+ # does the operand contain anything but digits?
+ if ! expr "$1" : "[[:digit:]]\+$" > /dev/null 2>&1; then
+ # can't use die(), because it wraps message() which wraps this function
+ echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_nondigits() encountered" \
+ "possibly malicious garbage \"$1\"" >&2
+ exit $SHELL_LIB_THROWN_ERROR
+ fi
+ shift
+ done
+}
+
+reject_whitespace () {
+ # syntax: reject_whitespace [ operand ]
+ #
+ # scan operand (typically a shell variable whose value cannot be trusted) for
+ # whitespace characters and barf if any are found
+ if [ -n "$1" ]; then
+ # does the operand contain any whitespace?
+ if expr "$1" : "[[:space:]]" > /dev/null 2>&1; then
+ # can't use die(), because I want to avoid forward references
+ echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_whitespace() encountered" \
+ "possibly malicious garbage \"$1\"" >&2
+ exit $SHELL_LIB_THROWN_ERROR
+ fi
+ fi
+}
+
+reject_unlikely_path_chars () {
+ # syntax: reject_unlikely_path_chars [ operand ... ]
+ #
+ # scan operands (typically shell variables whose values cannot be trusted) for
+ # characters unlikely to be seen in a path and which the shell might
+ # interpret and barf if any are found
+ while [ -n "$1" ]; do
+ # does the operand contain any funny characters?
+ if expr "$1" : '.*[!$&()*;<>?|].*' > /dev/null 2>&1; then
+ # can't use die(), because I want to avoid forward references
+ echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_unlikely_path_chars()" \
+ "encountered possibly malicious garbage \"$1\"" >&2
+ exit $SHELL_LIB_THROWN_ERROR
+ fi
+ shift
+ done
+}
+
+# Query the terminal to establish a default number of columns to use for
+# displaying messages to the user. This is used only as a fallback in the
+# event the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while
+# the script is running, and this cannot, only being calculated once.)
+DEFCOLUMNS=$(stty size 2> /dev/null | awk '{print $2}') || true
+if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" > /dev/null 2>&1; then
+ DEFCOLUMNS=80
+fi
+
+message () {
+ # pretty-print messages of arbitrary length
+ reject_nondigits "$COLUMNS"
+ echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2
+}
+
+observe () {
+ # syntax: observe message ...
+ #
+ # issue observational message suitable for logging someday when support for
+ # it exists in dpkg
+ if [ -n "$DEBUG_XORG_PACKAGE" ]; then
+ message "$THIS_PACKAGE $THIS_SCRIPT note: $*"
+ fi
+}
+
+warn () {
+ # syntax: warn message ...
+ #
+ # issue warning message suitable for logging someday when support for
+ # it exists in dpkg; also send to standard error
+ message "$THIS_PACKAGE $THIS_SCRIPT warning: $*"
+}
+
+die () {
+ # syntax: die message ...
+ #
+ # exit script with error message
+ message "$THIS_PACKAGE $THIS_SCRIPT error: $*"
+ exit $SHELL_LIB_THROWN_ERROR
+}
+
+internal_error () {
+ # exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
+ message "internal error: $*"
+ if [ -n "$OFFICIAL_BUILD" ]; then
+ message "Please report a bug in the $THIS_SCRIPT script of the" \
+ "$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \
+ "Tracking System. Include all messages above that mention the" \
+ "$THIS_PACKAGE package. Visit " \
+ "<http://www.debian.org/Bugs/Reporting> on the World Wide Web for" \
+ "instructions, read the file" \
+ "/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \
+ "package, or install the reportbug package and use the command of" \
+ "the same name to file a report."
+ fi
+ exit $SHELL_LIB_INTERNAL_ERROR
+}
+
+usage_error () {
+ message "usage error: $*"
+ message "Please report a bug in the $THIS_SCRIPT script of the" \
+ "$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \
+ "Tracking System. Include all messages above that mention the" \
+ "$THIS_PACKAGE package. Visit " \
+ "<http://www.debian.org/Bugs/Reporting> on the World Wide Web for" \
+ "instructions, read the file" \
+ "/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \
+ "package, or install the reportbug package and use the command of" \
+ "the same name to file a report."
+ exit $SHELL_LIB_USAGE_ERROR
+}
+
+
+maplink () {
+ # returns what symlink should point to; i.e., what the "sane" answer is
+ # Keep this in sync with the debian/*.links files.
+ # This is only needed for symlinks to directories.
+ #
+ # XXX: Most of these look wrong in the X11R7 world and need to be fixed.
+ # If we've stopped using this function, fixing it might enable us to re-enable
+ # it again and catch more errors.
+ case "$1" in
+ /etc/X11/xkb/compiled) echo /var/lib/xkb ;;
+ /etc/X11/xkb/xkbcomp) echo /usr/X11R6/bin/xkbcomp ;;
+ /usr/X11R6/lib/X11/app-defaults) echo /etc/X11/app-defaults ;;
+ /usr/X11R6/lib/X11/fs) echo /etc/X11/fs ;;
+ /usr/X11R6/lib/X11/lbxproxy) echo /etc/X11/lbxproxy ;;
+ /usr/X11R6/lib/X11/proxymngr) echo /etc/X11/proxymngr ;;
+ /usr/X11R6/lib/X11/rstart) echo /etc/X11/rstart ;;
+ /usr/X11R6/lib/X11/twm) echo /etc/X11/twm ;;
+ /usr/X11R6/lib/X11/xdm) echo /etc/X11/xdm ;;
+ /usr/X11R6/lib/X11/xinit) echo /etc/X11/xinit ;;
+ /usr/X11R6/lib/X11/xkb) echo /etc/X11/xkb ;;
+ /usr/X11R6/lib/X11/xserver) echo /etc/X11/xserver ;;
+ /usr/X11R6/lib/X11/xsm) echo /etc/X11/xsm ;;
+ /usr/bin/X11) echo ../X11R6/bin ;;
+ /usr/bin/rstartd) echo ../X11R6/bin/rstartd ;;
+ /usr/include/X11) echo ../X11R6/include/X11 ;;
+ /usr/lib/X11) echo ../X11R6/lib/X11 ;;
+ *) internal_error "maplink() called with unknown path \"$1\"" ;;
+ esac
+}
+
+analyze_path () {
+ # given a supplied set of pathnames, break each one up by directory and do an
+ # ls -dl on each component, cumulatively; i.e.
+ # analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
+ # Thanks to Randolph Chung for this clever hack.
+
+ local f g
+
+ while [ -n "$1" ]; do
+ reject_whitespace "$1"
+ g=
+ message "Analyzing $1:"
+ for f in $(echo "$1" | tr / \ ); do
+ if [ -e /$g$f ]; then
+ ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true
+ g=$g$f/
+ else
+ message "/$g$f: nonexistent; directory contents of /$g:"
+ ls -l /$g
+ break
+ fi
+ done
+ shift
+ done
+}
+
+find_culprits () {
+ local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
+ msg
+
+ reject_whitespace "$1"
+ message "Searching for overlapping packages..."
+ dpkg_info_dir=/var/lib/dpkg/info
+ if [ -d $dpkg_info_dir ]; then
+ if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then
+ possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \
+ "(xbase-clients|x11-common|xfs|xlibs)")
+ if [ -n "$possible_culprits" ]; then
+ smoking_guns=$(grep -l "$1" $possible_culprits || true)
+ if [ -n "$smoking_guns" ]; then
+ bad_packages=$(printf "\\n")
+ for f in $smoking_guns; do
+ # too bad you can't nest parameter expansion voodoo
+ p=${f%*.list} # strip off the trailing ".list"
+ package=${p##*/} # strip off the directories
+ bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
+ done
+ msg=$(cat <<EOF
+The following packages appear to have file overlaps with the X.Org packages;
+these packages are either very old, or in violation of Debian Policy. Try
+upgrading each of these packages to the latest available version if possible:
+for example, with the command "apt-get install". If no newer version of a
+package is available, you will have to remove it; for example, with the command
+"apt-get remove". If even the latest available version of the package has
+this file overlap, please file a bug against that package with the Debian Bug
+Tracking System. You may want to refer the package maintainer to section 12.8
+of the Debian Policy manual.
+EOF
+)
+ message "$msg"
+ message "The overlapping packages are: $bad_packages"
+ else
+ message "no overlaps found."
+ fi
+ fi
+ else
+ message "cannot search; no matches for $dpkg_info_dir/*.list."
+ fi
+ else
+ message "cannot search; $dpkg_info_dir does not exist."
+ fi
+}
+
+# we require a readlink command or shell function
+if ! which readlink > /dev/null 2>&1; then
+ message "The readlink command was not found. Please install version" \
+ "1.13.1 or later of the debianutils package."
+ readlink () {
+ # returns what symlink in $1 actually points to
+ perl -e '$l = shift; exit 1 unless -l $l; $r = readlink $l; exit 1 unless $r; print "$r\n"' "$1"
+ }
+fi
+
+check_symlink () {
+ # syntax: check_symlink symlink
+ #
+ # See if specified symlink points where it is supposed to. Return 0 if it
+ # does, and 1 if it does not.
+ #
+ # Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
+
+ local symlink
+
+ # validate arguments
+ if [ $# -ne 1 ]; then
+ usage_error "check_symlink() called with wrong number of arguments;" \
+ "expected 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ symlink="$1"
+
+ if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+check_symlinks_and_warn () {
+ # syntax: check_symlinks_and_warn symlink ...
+ #
+ # For each argument, check for symlink sanity, and warn if it isn't sane.
+ #
+ # Call this function from a preinst script in the event $1 is "upgrade" or
+ # "install".
+
+ local errmsg symlink
+
+ # validate arguments
+ if [ $# -lt 1 ]; then
+ usage_error "check_symlinks_and_warn() called with wrong number of" \
+ "arguments; expected at least 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ while [ -n "$1" ]; do
+ symlink="$1"
+ if [ -L "$symlink" ]; then
+ if ! check_symlink "$symlink"; then
+ observe "$symlink symbolic link points to wrong location" \
+ "$(readlink "$symlink"); removing"
+ rm "$symlink"
+ fi
+ elif [ -e "$symlink" ]; then
+ errmsg="$symlink exists and is not a symbolic link; this package cannot"
+ errmsg="$errmsg be installed until this"
+ if [ -f "$symlink" ]; then
+ errmsg="$errmsg file"
+ elif [ -d "$symlink" ]; then
+ errmsg="$errmsg directory"
+ else
+ errmsg="$errmsg thing"
+ fi
+ errmsg="$errmsg is removed"
+ die "$errmsg"
+ fi
+ shift
+ done
+}
+
+check_symlinks_and_bomb () {
+ # syntax: check_symlinks_and_bomb symlink ...
+ #
+ # For each argument, check for symlink sanity, and bomb if it isn't sane.
+ #
+ # Call this function from a postinst script.
+
+ local problem symlink
+
+ # validate arguments
+ if [ $# -lt 1 ]; then
+ usage_error "check_symlinks_and_bomb() called with wrong number of"
+ "arguments; expected at least 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ while [ -n "$1" ]; do
+ problem=
+ symlink="$1"
+ if [ -L "$symlink" ]; then
+ if ! check_symlink "$symlink"; then
+ problem=yes
+ warn "$symlink symbolic link points to wrong location" \
+ "$(readlink "$symlink")"
+ fi
+ elif [ -e "$symlink" ]; then
+ problem=yes
+ warn "$symlink is not a symbolic link"
+ else
+ problem=yes
+ warn "$symlink symbolic link does not exist"
+ fi
+ if [ -n "$problem" ]; then
+ analyze_path "$symlink" "$(readlink "$symlink")"
+ find_culprits "$symlink"
+ die "bad symbolic links on system"
+ fi
+ shift
+ done
+}
+
+font_update () {
+ # run $UPDATECMDS in $FONTDIRS
+
+ local dir cmd shortcmd x_font_dir_prefix
+
+ x_font_dir_prefix="/usr/share/fonts/X11"
+
+ if [ -z "$UPDATECMDS" ]; then
+ usage_error "font_update() called but \$UPDATECMDS not set"
+ fi
+ if [ -z "$FONTDIRS" ]; then
+ usage_error "font_update() called but \$FONTDIRS not set"
+ fi
+
+ reject_unlikely_path_chars "$UPDATECMDS"
+ reject_unlikely_path_chars "$FONTDIRS"
+
+ for dir in $FONTDIRS; do
+ if [ -d "$x_font_dir_prefix/$dir" ]; then
+ for cmd in $UPDATECMDS; do
+ if which "$cmd" > /dev/null 2>&1; then
+ shortcmd=${cmd##*/}
+ observe "running $shortcmd in $dir font directory"
+ cmd_opts=
+ if [ "$shortcmd" = "update-fonts-alias" ]; then
+ cmd_opts=--x11r7-layout
+ fi
+ if [ "$shortcmd" = "update-fonts-dir" ]; then
+ cmd_opts=--x11r7-layout
+ fi
+ if [ "$shortcmd" = "update-fonts-scale" ]; then
+ cmd_opts=--x11r7-layout
+ fi
+ $cmd $cmd_opts $dir || warn "$cmd $cmd_opts $dir" \
+ "failed; font directory data may not" \
+ "be up to date"
+ else
+ warn "$cmd not found; not updating corresponding $dir font" \
+ "directory data"
+ fi
+ done
+ else
+ warn "$dir is not a directory; not updating font directory data"
+ fi
+ done
+}
+
+remove_conffile_prepare () {
+ # syntax: remove_conffile_prepare filename official_md5sum ...
+ #
+ # Check a conffile "filename" against a list of canonical MD5 checksums.
+ # If the file's current MD5 checksum matches one of the "official_md5sum"
+ # operands provided, then prepare the conffile for removal from the system.
+ # We defer actual deletion until the package is configured so that we can
+ # roll this operation back if package installation fails.
+ #
+ # Call this function from a preinst script in the event $1 is "upgrade" or
+ # "install" and verify $2 to ensure the package is being upgraded from a
+ # version (or installed over a version removed-but-not-purged) prior to the
+ # one in which the conffile was obsoleted.
+
+ local conffile current_checksum
+
+ # validate arguments
+ if [ $# -lt 2 ]; then
+ usage_error "remove_conffile_prepare() called with wrong number of" \
+ "arguments; expected at least 2, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ conffile="$1"
+ shift
+
+ # does the conffile even exist?
+ if [ -e "$conffile" ]; then
+ # calculate its checksum
+ current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//')
+ # compare it to each supplied checksum
+ while [ -n "$1" ]; do
+ if [ "$current_checksum" = "$1" ]; then
+ # we found a match; move the confffile and stop looking
+ observe "preparing obsolete conffile $conffile for removal"
+ mv "$conffile" "$conffile.$THIS_PACKAGE-tmp"
+ break
+ fi
+ shift
+ done
+ fi
+}
+
+remove_conffile_lookup () {
+ # syntax: remove_conffile_lookup package filename
+ #
+ # Lookup the md5sum of a conffile in dpkg's database, and prepare for removal
+ # if it matches the actual file's md5sum.
+ #
+ # Call this function when you would call remove_conffile_prepare but only
+ # want to check against dpkg's status database instead of known checksums.
+
+ local package conffile old_md5sum
+
+ # validate arguments
+ if [ $# -ne 2 ]; then
+ usage_error "remove_conffile_lookup() called with wrong number of" \
+ "arguments; expected 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ package="$1"
+ conffile="$2"
+
+ if ! [ -e "$conffile" ]; then
+ return
+ fi
+ old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$package" | \
+ awk '{ if (match($0, "^ '"$conffile"' ")) print $2}')"
+ if [ -n "$old_md5sum" ]; then
+ remove_conffile_prepare "$conffile" "$old_md5sum"
+ fi
+}
+
+remove_conffile_commit () {
+ # syntax: remove_conffile_commit filename
+ #
+ # Complete the removal of a conffile "filename" that has become obsolete.
+ #
+ # Call this function from a postinst script after having used
+ # remove_conffile_prepare() in the preinst.
+
+ local conffile
+
+ # validate arguments
+ if [ $# -ne 1 ]; then
+ usage_error "remove_conffile_commit() called with wrong number of" \
+ "arguments; expected 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ conffile="$1"
+
+ # if the temporary file created by remove_conffile_prepare() exists, remove it
+ if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
+ observe "committing removal of obsolete conffile $conffile"
+ rm "$conffile.$THIS_PACKAGE-tmp"
+ fi
+}
+
+remove_conffile_rollback () {
+ # syntax: remove_conffile_rollback filename
+ #
+ # Roll back the removal of a conffile "filename".
+ #
+ # Call this function from a postrm script in the event $1 is "abort-upgrade"
+ # or "abort-install" is after having used remove_conffile_prepare() in the
+ # preinst.
+
+ local conffile
+
+ # validate arguments
+ if [ $# -ne 1 ]; then
+ usage_error "remove_conffile_rollback() called with wrong number of" \
+ "arguments; expected 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ conffile="$1"
+
+ # if the temporary file created by remove_conffile_prepare() exists, move it
+ # back
+ if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
+ observe "rolling back removal of obsolete conffile $conffile"
+ mv "$conffile.$THIS_PACKAGE-tmp" "$conffile"
+ fi
+}
+
+replace_conffile_with_symlink_prepare () {
+ # syntax: replace_conffile_with_symlink_prepare oldfilename newfilename \
+ # official_md5sum ...
+ #
+ # Check a conffile "oldfilename" against a list of canonical MD5 checksums.
+ # If the file's current MD5 checksum matches one of the "official_md5sum"
+ # operands provided, then prepare the conffile for removal from the system.
+ # We defer actual deletion until the package is configured so that we can
+ # roll this operation back if package installation fails. Otherwise copy it
+ # to newfilename and let dpkg handle it through conffiles mechanism.
+ #
+ # Call this function from a preinst script in the event $1 is "upgrade" or
+ # "install" and verify $2 to ensure the package is being upgraded from a
+ # version (or installed over a version removed-but-not-purged) prior to the
+ # one in which the conffile was obsoleted.
+
+ local conffile current_checksum
+
+ # validate arguments
+ if [ $# -lt 3 ]; then
+ usage_error "replace_conffile_with_symlink_prepare() called with wrong" \
+ " number of arguments; expected at least 3, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ oldconffile="$1"
+ shift
+ newconffile="$1"
+ shift
+
+ remove_conffile_prepare "$_oldconffile" "$@"
+ # If $oldconffile still exists, then md5sums didn't match.
+ # Copy it to new one.
+ if [ -f "$oldconffile" ]; then
+ cp "$oldconffile" "$newconffile"
+ fi
+
+}
+
+replace_conffile_with_symlink_commit () {
+ # syntax: replace_conffile_with_symlink_commit oldfilename
+ #
+ # Complete the removal of a conffile "oldfilename" that has been
+ # replaced by a symlink.
+ #
+ # Call this function from a postinst script after having used
+ # replace_conffile_with_symlink_prepare() in the preinst.
+
+ local conffile
+
+ # validate arguments
+ if [ $# -ne 1 ]; then
+ usage_error "replace_conffile_with_symlink_commit() called with wrong" \
+ "number of arguments; expected 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ conffile="$1"
+
+ remove_conffile_commit "$conffile"
+}
+
+replace_conffile_with_symlink_rollback () {
+ # syntax: replace_conffile_with_symlink_rollback oldfilename newfilename
+ #
+ # Roll back the replacing of a conffile "oldfilename" with symlink to
+ # "newfilename".
+ #
+ # Call this function from a postrm script in the event $1 is "abort-upgrade"
+ # or "abort-install" and verify $2 to ensure the package failed to upgrade
+ # from a version (or install over a version removed-but-not-purged) prior
+ # to the one in which the conffile was obsoleted.
+ # You should have used replace_conffile_with_symlink_prepare() in the
+ # preinst.
+
+ local conffile
+
+ # validate arguments
+ if [ $# -ne 2 ]; then
+ usage_error "replace_conffile_with_symlink_rollback() called with wrong" \
+ "number of arguments; expected 2, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ oldconffile="$1"
+ newconffile="$2"
+
+ remove_conffile_rollback "$_oldconffile"
+ if [ -f "$newconffile" ]; then
+ rm "$newconffile"
+ fi
+}
+
+run () {
+ # syntax: run command [ argument ... ]
+ #
+ # Run specified command with optional arguments and report its exit status.
+ # Useful for commands whose exit status may be nonzero, but still acceptable,
+ # or commands whose failure is not fatal to us.
+ #
+ # NOTE: Do *not* use this function with db_get or db_metaget commands; in
+ # those cases the return value of the debconf command *must* be checked
+ # before the string returned by debconf is used for anything.
+
+ local retval
+
+ # validate arguments
+ if [ $# -lt 1 ]; then
+ usage_error "run() called with wrong number of arguments; expected at" \
+ "least 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ "$@" || retval=$?
+
+ if [ ${retval:-0} -ne 0 ]; then
+ observe "command \"$*\" exited with status $retval"
+ fi
+}
+
+make_symlink_sane () {
+ # syntax: make_symlink_sane symlink target
+ #
+ # Ensure that the symbolic link symlink exists, and points to target.
+ #
+ # If symlink does not exist, create it and point it at target.
+ #
+ # If symlink exists but is not a symbolic link, back it up.
+ #
+ # If symlink exists, is a symbolic link, but points to the wrong location, fix
+ # it.
+ #
+ # If symlink exists, is a symbolic link, and already points to target, do
+ # nothing.
+ #
+ # This function wouldn't be needed if ln had an -I, --idempotent option.
+
+ # Validate arguments.
+ if [ $# -ne 2 ]; then
+ usage_error "make_symlink_sane() called with wrong number of arguments;" \
+ "expected 2, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ # We could just use the positional parameters as-is, but that makes things
+ # harder to follow.
+ local symlink target
+
+ symlink="$1"
+ target="$2"
+
+ if [ -L "$symlink" ] && [ "$(readlink "$symlink")" = "$target" ]; then
+ observe "link from $symlink to $target already exists"
+ else
+ observe "creating symbolic link from $symlink to $target"
+ mkdir -p "${target%/*}" "${symlink%/*}"
+ ln -s -b -S ".dpkg-old" "$target" "$symlink"
+ fi
+}
+
+migrate_dir_to_symlink () {
+ # syntax: migrate_dir_to_symlink old_location new_location
+ #
+ # Per Debian Policy section 6.5.4, "A directory will never be replaced by a
+ # symbolic link to a directory or vice versa; instead, the existing state
+ # (symlink or not) will be left alone and dpkg will follow the symlink if
+ # there is one."
+ #
+ # We have to do it ourselves.
+ #
+ # This function moves the contents of old_location, a directory, into
+ # new_location, a directory, then makes old_location a symbolic link to
+ # new_location.
+ #
+ # old_location need not exist, but if it does, it must be a directory (or a
+ # symlink to a directory). If it is not, it is backed up. If new_location
+ # exists already and is not a directory, it is backed up.
+ #
+ # This function should be called from a package's preinst so that other
+ # packages unpacked after this one --- but before this package's postinst runs
+ # --- are unpacked into new_location even if their payloads contain
+ # old_location filespecs.
+
+ # Validate arguments.
+ if [ $# -ne 2 ]; then
+ usage_error "migrate_dir_to_symlink() called with wrong number of"
+ "arguments; expected 2, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ # We could just use the positional parameters as-is, but that makes things
+ # harder to follow.
+ local new old
+
+ old="$1"
+ new="$2"
+
+ # Is old location a symlink?
+ if [ -L "$old" ]; then
+ # Does it already point to new location?
+ if [ "$(readlink "$old")" = "$new" ]; then
+ # Nothing to do; migration has already been done.
+ observe "migration of $old to $new already done"
+ return 0
+ else
+ # Back it up.
+ warn "backing up symbolic link $old as $old.dpkg-old"
+ mv -b "$old" "$old.dpkg-old"
+ fi
+ fi
+
+ # Does old location exist, but is not a directory?
+ if [ -e "$old" ] && ! [ -d "$old" ]; then
+ # Back it up.
+ warn "backing up non-directory $old as $old.dpkg-old"
+ mv -b "$old" "$old.dpkg-old"
+ fi
+
+ observe "migrating $old to $new"
+
+ # Is new location a symlink?
+ if [ -L "$new" ]; then
+ # Does it point the wrong way, i.e., back to where we're migrating from?
+ if [ "$(readlink "$new")" = "$old" ]; then
+ # Get rid of it.
+ observe "removing symbolic link $new which points to $old"
+ rm "$new"
+ else
+ # Back it up.
+ warn "backing up symbolic link $new as $new.dpkg-old"
+ mv -b "$new" "$new.dpkg-old"
+ fi
+ fi
+
+ # Does new location exist, but is not a directory?
+ if [ -e "$new" ] && ! [ -d "$new" ]; then
+ warn "backing up non-directory $new as $new.dpkg-old"
+ mv -b "$new" "$new.dpkg-old"
+ fi
+
+ # Create new directory if it does not yet exist.
+ if ! [ -e "$new" ]; then
+ observe "creating $new"
+ mkdir -p "$new"
+ fi
+
+ # Copy files in old location to new location. Back up any filenames that
+ # already exist in the new location with the extension ".dpkg-old".
+ observe "copying files from $old to $new"
+ if ! (cd "$old" && cp -a -b -S ".dpkg-old" . "$new"); then
+ die "error(s) encountered while copying files from $old to $new"
+ fi
+
+ # Remove files at old location.
+ observe "removing $old"
+ rm -r "$old"
+
+ # Create symlink from old location to new location.
+ make_symlink_sane "$old" "$new"
+}
+
+# vim:set ai et sw=2 ts=2 tw=80:
+
+# GOBSTOPPER: The X Strike Force shell library ends here.
--- /dev/null
+# $Id$
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation.
+#
+# 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 OPEN GROUP 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.
+#
+# Except as contained in this notice, the name of the copyright holders shall
+# not be used in advertising or otherwise to promote the sale, use or
+# other dealings in this Software without prior written authorization
+# from the copyright holders.
+#
+
+drivermandir = $(DRIVER_MAN_DIR)
+
+driverman_PRE = @DRIVER_NAME@.man
+
+driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
+
+EXTRA_DIST = @DRIVER_NAME@.man
+
+CLEANFILES = $(driverman_DATA)
+
+SED = sed
+
+# Strings to replace in man pages
+XORGRELSTRING = @PACKAGE_STRING@
+ XORGMANNAME = X Version 11
+
+MAN_SUBSTS = \
+ -e 's|__vendorversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
+ -e 's|__xorgversion__|"$(XORGRELSTRING)" "$(XORGMANNAME)"|' \
+ -e 's|__xservername__|Xorg|g' \
+ -e 's|__xconfigfile__|xorg.conf|g' \
+ -e 's|__projectroot__|$(prefix)|g' \
+ -e 's|__appmansuffix__|$(APP_MAN_SUFFIX)|g' \
+ -e 's|__drivermansuffix__|$(DRIVER_MAN_SUFFIX)|g' \
+ -e 's|__adminmansuffix__|$(ADMIN_MAN_SUFFIX)|g' \
+ -e 's|__miscmansuffix__|$(MISC_MAN_SUFFIX)|g' \
+ -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g'
+
+SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+.man.$(DRIVER_MAN_SUFFIX):
+ sed $(MAN_SUBSTS) < $< > $@
--- /dev/null
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.man,v 1.2 2001/01/27 18:20:47 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH FBDEV __drivermansuffix__ __vendorversion__
+.SH NAME
+fbdev \- video driver for framebuffer device
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qfbdev\*q"
+.BI " BusID \*qpci:" bus : dev : func \*q
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B fbdev
+is an __xservername__ driver for framebuffer devices. This is a non-accelerated
+driver, the following framebuffer depths are supported: 8, 15, 16, 24.
+All visual types are supported for depth 8, and TrueColor visual is
+supported for the other depths. Multi-head configurations are supported.
+.SH SUPPORTED HARDWARE
+The
+.B fbdev
+driver supports all hardware where a framebuffer driver is available.
+fbdev uses the os-specific submodule fbdevhw(__drivermansuffix__) to talk
+to the kernel
+device driver. Currently a fbdevhw module is available for linux.
+.SH CONFIGURATION DETAILS
+Please refer to __xconfigfile__(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to
+this driver.
+.PP
+For this driver it is not required to specify modes in the screen
+section of the config file. The
+.B fbdev
+driver can pick up the currently used video mode from the framebuffer
+driver and will use it if there are no video modes configured.
+.PP
+For PCI boards you might have to add a BusID line to the Device
+section. See above for a sample line. You can use \*q\__xservername__
+-scanpci\*q
+to figure out the correct values.
+.PP
+The following driver
+.B Options
+are supported:
+.TP
+.BI "Option \*qfbdev\*q \*q" string \*q
+The framebuffer device to use. Default: /dev/fb0.
+.TP
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
+Enable or disable use of the shadow framebuffer layer. Default: on.
+.TP
+.BI "Option \*qRotate\*q \*q" string \*q
+Enable rotation of the display. The supported values are "CW" (clockwise,
+90 degrees), "UD" (upside down, 180 degrees) and "CCW" (counter clockwise,
+270 degrees). Implies use of the shadow framebuffer layer. Default: off.
+.SH "SEE ALSO"
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__),
+X(__miscmansuffix__), fbdevhw(__drivermansuffix__)
+.SH AUTHORS
+Authors include: Gerd Knorr, Michel D\(:anzer, Geert Uytterhoeven
--- /dev/null
+AM_CFLAGS = -I@top_srcdir@/src @XORG_CFLAGS@ @EMULFB_CFLAGS@
+emulfb_drv_la_LTLIBRARIES = emulfb_drv.la
+#emulfb_drv_la_LDFLAGS = -module -avoid-version @EMULFB_LIBS@
+emulfb_drv_la_LDFLAGS = -module -avoid-version
+emulfb_drv_la_LIBADD = @EMULFB_LIBS@
+emulfb_drv_ladir = @moduledir@/drivers
+
+# common
+emulfb_drv_la_SOURCES = \
+ fbdev.c \
+ fbdev_dpms.c
+
+# v4l2
+emulfb_drv_la_SOURCES += \
+ v4l2/v4l2api.c \
+ v4l2/v4l2_output_api.c
+AM_CFLAGS += -I@top_srcdir@/src/v4l2
+
+# xv
+emulfb_drv_la_SOURCES += \
+ xv/fbdev_video.c
+AM_CFLAGS += -I@top_srcdir@/src/xv
+
+# fbdevhw
+emulfb_drv_la_SOURCES += \
+ fbdevhw/fbdev_hw.c
+AM_CFLAGS += -I@top_srcdir@/src/fbdevhw
+
+# util
+emulfb_drv_la_SOURCES += \
+ util/fbdev_util.c \
+ util/fbdev_pixman.c
+AM_CFLAGS += -I@top_srcdir@/src/util
+
+# crtcconfig
+emulfb_drv_la_SOURCES += \
+ crtcconfig/fbdev_crtcconfig.c \
+ crtcconfig/fbdev_crtc.c \
+ crtcconfig/lcd_output.c \
+ crtcconfig/fbdev_mode.c
+AM_CFLAGS += -I@top_srcdir@/src/crtcconfig
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <unistd.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <math.h>
+
+#include "xace.h"
+#include "xacestr.h"
+#include <X11/Xatom.h>
+
+#include "fbdev.h"
+#include "fbdevhw.h"
+#include "fbdev_hw.h"
+#include "fbdev_crtc_priv.h"
+#include "fbdev_util.h"
+
+#include "xf86Crtc.h"
+#include "xf86Xinput.h"
+#include "exevents.h"
+
+/********************************************************************************************/
+/* Implementation of Crtc entry points */
+/********************************************************************************************/
+/**
+ * Turns the crtc on/off, or sets intermediate power levels if available.
+ *
+ * Unsupported intermediate modes drop to the lower power setting. If the
+ * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
+ * be safe to call mode_set.
+ */
+static void fbdev_crtc_dpms(xf86CrtcPtr crtc, int mode)
+{
+ return;
+}
+
+/**
+ * Lock CRTC prior to mode setting, mostly for DRI.
+ * Returns whether unlock is needed
+ */
+static Bool fbdev_crtc_lock(xf86CrtcPtr crtc)
+{
+
+ /* check whether unlock is needed */
+ return TRUE;
+}
+
+/**
+ * Lock CRTC prior to mode setting, mostly for DRI.
+ * Returns whether unlock is needed
+ */
+static void fbdev_crtc_unlock(xf86CrtcPtr crtc)
+{
+ return;
+}
+
+
+/**
+ * Callback to adjust the mode to be set in the CRTC.
+ *
+ * This allows a CRTC to adjust the clock or even the entire set of
+ * timings, which is used for panels with fixed timings or for
+ * buses with clock limitations.
+ */
+static Bool fbdev_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+{
+ return TRUE;
+}
+
+/**
+ * Prepare CRTC for an upcoming mode set.
+ */
+static void fbdev_crtc_prepare(xf86CrtcPtr crtc)
+{
+
+}
+
+/**
+ * Callback for setting up a video mode after fixups have been made.
+ */
+static void fbdev_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode, int x, int y)
+{
+
+}
+
+/**
+ * Commit mode changes to a CRTC
+ */
+static void fbdev_crtc_commit(xf86CrtcPtr crtc)
+{
+
+}
+
+/* Set the color ramps for the CRTC to the given values. */
+static void fbdev_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green,
+ CARD16 * blue, int size)
+{
+
+}
+
+/**
+ * Set cursor colors
+ */
+void fbdev_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
+{
+ return;
+}
+
+/**
+ * Set cursor position
+ */
+void fbdev_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
+{
+
+ return;
+}
+
+/**
+ * Show cursor
+ */
+void fbdev_crtc_show_cursor(xf86CrtcPtr crtc)
+{
+
+ return;
+}
+
+/**
+ * Hide cursor
+ */
+void fbdev_crtc_hide_cursor(xf86CrtcPtr crtc)
+{
+
+ return;
+}
+
+/**
+ * Load ARGB image
+ */
+void fbdev_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
+{
+
+ return;
+}
+
+/**
+ * Less fine-grained mode setting entry point for kernel modesetting
+ */
+Bool fbdev_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, int x, int y)
+{
+ return TRUE;
+}
+
+
+/**
+ * Callback for panning. Doesn't change the mode.
+ * Added in ABI version 2
+ */
+static void fbdev_crtc_set_origin(xf86CrtcPtr crtc, int x, int y)
+{
+ xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "set_origin: unimplemented");
+ return; /* XXX implement */
+}
+
+/* crtc funcs */
+static const xf86CrtcFuncsRec fbdev_crtc_funcs =
+{
+ .dpms = fbdev_crtc_dpms,
+ .save = NULL, /* XXX */
+ .restore = NULL, /* XXX */
+ .lock = fbdev_crtc_lock,
+ .unlock = fbdev_crtc_unlock,
+ .mode_fixup = fbdev_crtc_mode_fixup,
+
+ .prepare = fbdev_crtc_prepare,
+ .mode_set = fbdev_crtc_mode_set,
+ .commit = fbdev_crtc_commit,
+ .gamma_set = fbdev_crtc_gamma_set,
+
+ .shadow_create = NULL,
+ .shadow_allocate = NULL,
+ .shadow_destroy = NULL,
+
+ .set_cursor_colors = fbdev_crtc_set_cursor_colors,
+ .set_cursor_position = fbdev_crtc_set_cursor_position,
+ .show_cursor = fbdev_crtc_show_cursor,
+ .hide_cursor = fbdev_crtc_hide_cursor,
+ .load_cursor_argb = fbdev_crtc_load_cursor_argb,
+ .destroy = NULL, /* XXX */
+ .set_mode_major = NULL, /*???*/
+#if RANDR_13_INTERFACE
+ .set_origin = fbdev_crtc_set_origin,
+#endif
+};
+
+void FBDevCrtcInit(ScrnInfoPtr pScrn, int num)
+{
+ xf86CrtcPtr crtc;
+ FBDevCrtcPrivPtr fbdev_crtc;
+
+ crtc = xf86CrtcCreate (pScrn, &fbdev_crtc_funcs);
+ if (crtc == NULL)
+ return;
+
+ fbdev_crtc = xnfcalloc (sizeof (FBDevCrtcPriv), 1);
+ if (!fbdev_crtc)
+ {
+ xf86CrtcDestroy (crtc);
+ return;
+ }
+
+ crtc->driver_private = fbdev_crtc;
+
+}
+
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 _FBDEV_CRTC_PRIV_H_
+#define _FBDEV_CRTC_PRIV_H_
+
+#include "fbdev.h"
+
+/* fbdev crtc private infomation */
+typedef struct _fbdevCrtcPriv
+{
+ int type;
+
+} FBDevCrtcPriv, *FBDevCrtcPrivPtr;
+#define FBDEVCRTCPTR(o) ((FBDevCrtcPrivPtr)((o)->driver_private))
+
+void FBDevCrtcInit(ScrnInfoPtr pScrn, int num);
+#endif // _FBDEV_CRTC_PRIV_H_
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "fbdev.h"
+#include "fbdevhw.h"
+#include "fbdev_crtcconfig.h"
+#include "fbdev_crtc_priv.h"
+#include "fbdev_output_priv.h"
+
+#include "xf86Crtc.h"
+
+#define MIN_CRTC_DPY_WIDTH 320
+#define MAX_CRTC_DPY_WIDTH 1024
+#define MIN_CRTC_DPY_HEIGHT 200
+#define MAX_CRTC_DPY_HEIGHT 1024
+
+#define NUM_CRTCS 1
+
+/**
+ * Requests that the driver resize the screen.
+ *
+ * The driver is responsible for updating scrn->virtualX and scrn->virtualY.
+ * If the requested size cannot be set, the driver should leave those values
+ * alone and return FALSE.
+ *
+ * A naive driver that cannot reallocate the screen may simply change
+ * virtual[XY]. A more advanced driver will want to also change the
+ * devPrivate.ptr and devKind of the screen pixmap, update any offscreen
+ * pixmaps it may have moved, and change pScrn->displayWidth.
+ */
+static Bool fbdev_crtc_config_resize (ScrnInfoPtr scrn, int width, int height)
+{
+
+ scrn->virtualX = width;
+ scrn->virtualY = height;
+
+ return TRUE;
+}
+
+
+/* crtc_config_func */
+static const xf86CrtcConfigFuncsRec fbdev_crtc_config_funcs =
+{
+ .resize = fbdev_crtc_config_resize,
+};
+
+
+/*
+ * Initialize the CrtcConfig.
+ * And initialize the mode setting throught create the avaliable crtcs and outputs
+ * then Initialize the Configuration of Crtc
+ */
+Bool FBDevCrtcConfigInit(ScrnInfoPtr pScrn)
+{
+ int min_width, max_width, min_height, max_height;
+ xf86CrtcConfigPtr crtc_config;
+ int i, o, c;
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+ /* TODO: check this routines later whether it is right setting */
+ {
+
+ fbdevHWUseBuildinMode(pScrn); /* sets pScrn->modes */
+ pScrn->modes = xf86DuplicateMode(pScrn->modes); /* well done, fbdevhw. */
+ pScrn->modes->name = NULL; /* fbdevhw string can't be freed */
+ pScrn->modes->type = M_T_DRIVER | M_T_PREFERRED;
+ pScrn->currentMode = pScrn->modes;
+ pFBDev->builtin = xf86DuplicateMode(pScrn->modes);
+
+ }
+
+ /* allocate an xf86CrtcConfig */
+ xf86CrtcConfigInit(pScrn, &fbdev_crtc_config_funcs);
+ crtc_config = XF86_CRTC_CONFIG_PTR (pScrn);
+
+ min_width = pScrn->modes->HDisplay;
+ max_width = pScrn->modes->HDisplay;
+ min_height = pScrn->modes->VDisplay;
+ max_height = pScrn->modes->VDisplay;
+
+ xf86CrtcSetSizeRange(pScrn, min_width, min_height, max_width, max_height);
+
+ /* set up the crtcs */
+ for( i = 0; i < NUM_CRTCS; i++)
+ FBDevCrtcInit(pScrn, i);
+
+ /* set up the outputs */
+ LcdOutputInit(pScrn);
+
+ /* [TODO]: set the crtc to the output in some manner ???? */
+ for (o = 0; o < crtc_config->num_output; o++)
+ {
+ xf86OutputPtr output = crtc_config->output[o];
+ int crtc_mask;
+
+ crtc_mask = 0;
+ for (c = 0; c < crtc_config->num_crtc; c++)
+ {
+ crtc_mask |= (1 << c);
+ }
+ output->possible_crtcs = crtc_mask;
+ output->possible_clones = FALSE;
+ }
+
+ /* initialize the configuration */
+ if(!xf86InitialConfiguration(pScrn, TRUE))
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 _FBDEV_CRTCCONFIG_H_
+#define _FBDEV_CRTCCONFIG_H_
+
+Bool FBDevCrtcConfigInit(ScrnInfoPtr pScrn);
+
+
+#endif // _FBDEV_CRTCCONFIG_H_
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "fbdev.h"
+
+#include <linux/fb.h>
+#include "fbdev_hw.h"
+#include "fbdev_mode.h"
+
+typedef struct _FBDevDisplayModeRec
+{
+ char name[32]; /* identifier for the mode */
+
+ /* These are the values that the user sees/provides */
+ int Clock; /* pixel clock freq (kHz) */
+ int HDisplay; /* horizontal timing */
+ int HSyncStart;
+ int HSyncEnd;
+ int HTotal;
+ int HSkew;
+ int VDisplay; /* vertical timing */
+ int VSyncStart;
+ int VSyncEnd;
+ int VTotal;
+ int VScan;
+ int Flags;
+
+} FBDevDisplayModeRec, *FBDevDisplayModePtr;
+
+/* [soolim: 20100206][TODO] : it has to be recalculated when it comes to change the target framebuffer
+ * The display mode data has to be changed whenever the target is changed
+ * Always check it out.
+ */
+const FBDevDisplayModeRec fbdevDisplayModes[] =
+{
+ /* CGA ( 320 x 200 ) */
+ {"320x200", 38, 320, 336, 338, 354, 0, 200, 203, 205, 233, 0, 0,},
+ /* QVGA ( 320 x 240 ) */
+ {"320x240", 38, 320, 336, 338, 354, 0, 240, 243, 245, 273, 0, 0,},
+ /* XX ( 240 x 400 ) */
+ {"240x400", 38, 240, 256, 258, 274, 0, 400, 428, 430, 433, 0, 0,},
+ /* HVGA (320 x 480 ) */
+ {"320x480", 38, 320, 336, 338, 354, 0, 480, 483, 485, 513, 0, 0,},
+ /* WVGA ( 480 x 720 ) */
+ {"480x720", 38, 480, 496, 498, 514, 0, 720, 723, 725, 753, 0, 0},
+ /* WVGA ( 480 x 800 ) */
+ {"480x800", 38, 480, 496, 498, 514, 0, 800, 803, 805, 833, 0, 0},
+ /* VGA ( 640 x 480 ) */
+ {"640x480", 19, 640, 840, 880, 959, 0, 480, 491, 501, 511, 0, 0,},
+ /* NTSC ( 720 x 480 ) */
+ {"720x480", 19, 720, 920, 960, 1039, 0, 480, 491, 501, 511, 0, 0,},
+ /* PAL ( 768 x 576 ) */
+ {"768x576", 19, 768, 968, 1008, 1087, 0, 576, 587, 597, 607, 0, 0,},
+ /* WVGA ( 800 x 480 ) */
+ {"800x480", 19, 800, 1000, 1040, 1119, 0, 480, 491, 501, 511, 0, 0},
+ /* WVGA ( 854 x 480 ) */
+ {"854x480", 19, 854, 1054, 1094, 1173, 0, 480, 491, 501, 511, 0, 0,},
+ /* WSVGA ( 600 x 1024 ) */
+ {"600x1024", 19, 600, 611, 621, 631, 0, 1024, 1224, 1264, 1343, 0, 0},
+ /* WSVGA ( 1024 x 600 ) */
+ {"1024x600", 19, 1024, 1224, 1264, 1343, 0, 600, 611, 621, 631, 0, 0},
+#if 0
+ /* XGA ( 1024 x 768 ) */
+ {"1024x768", 19, 1024, 1224, 1264, 1343, 600, 611, 621, 631, 0,},
+#endif
+};
+
+
+#define NUM_DISPLAY_MODES (sizeof(fbdevDisplayModes)/sizeof(fbdevDisplayModes[0]))
+
+const int fbdevNumDisplayModes = NUM_DISPLAY_MODES;
+
+
+DisplayModePtr
+FBDevGetSupportModes(DisplayModePtr builtin_mode)
+{
+ DisplayModePtr pMode = NULL;
+ DisplayModePtr prev_pMode = NULL;
+ DisplayModePtr ret_pMode = NULL;
+ int i;
+ int clock = 0;
+ if(builtin_mode)
+ clock = builtin_mode->Clock;
+ else
+ clock = 0;
+
+ for(i=0; i< fbdevNumDisplayModes; i++)
+ {
+ pMode = calloc(1, sizeof(DisplayModeRec));
+ pMode->next = NULL;
+ pMode->prev = NULL;
+ pMode->name = calloc(1, sizeof(char)*32);
+ sprintf(pMode->name,"%s", fbdevDisplayModes[i].name);
+ pMode->status = MODE_OK;
+ pMode->type = M_T_DRIVER | M_T_PREFERRED;
+
+ pMode->Clock = clock;
+ pMode->HDisplay = fbdevDisplayModes[i].HDisplay;
+ pMode->HSyncStart = fbdevDisplayModes[i].HSyncStart;
+ pMode->HSyncEnd = fbdevDisplayModes[i].HSyncEnd;
+ pMode->HTotal = fbdevDisplayModes[i].HTotal;
+ pMode->HSkew = fbdevDisplayModes[i].HSkew;
+ pMode->VDisplay = fbdevDisplayModes[i].VDisplay;
+ pMode->VSyncStart = fbdevDisplayModes[i].VSyncStart;
+ pMode->VSyncEnd = fbdevDisplayModes[i].VSyncEnd;
+ pMode->VTotal = fbdevDisplayModes[i].VTotal;
+ pMode->VScan = fbdevDisplayModes[i].VScan;
+ pMode->Flags = fbdevDisplayModes[i].Flags;
+
+ if(prev_pMode)
+ {
+ pMode->prev = prev_pMode;
+ prev_pMode->next = pMode;
+ prev_pMode = prev_pMode->next;
+ }
+ else
+ {
+ prev_pMode = pMode;
+ ret_pMode = pMode;
+ }
+
+ pMode = NULL;
+ }
+
+ return ret_pMode;
+}
+
+#define OPTION_PREFERRED_MODE 0
+
+char *
+FBDevCheckPreferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output)
+{
+ char *preferred_mode = NULL;
+
+ /* Check for a configured preference for a particular mode */
+ preferred_mode = xf86GetOptValString (output->options,
+ OPTION_PREFERRED_MODE);
+ if (preferred_mode)
+ return preferred_mode;
+
+ if (pScrn->display->modes && *pScrn->display->modes)
+ preferred_mode = *pScrn->display->modes;
+
+ return preferred_mode;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 FBDEV_MODE_H
+#define FBDEV_MODE_H
+
+#include "xf86Crtc.h"
+
+DisplayModePtr
+FBDevGetSupportModes(DisplayModePtr builtin_mode);
+
+char *
+FBDevCheckPreferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output);
+
+#endif //FBDEV_MODE_H
+
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 _FBDEV_OUTPUT_PRIV_H_
+#define _FBDEV_OUTPUT_PRIV_H_
+
+/* fbdev output private infomation */
+typedef struct _fbdevOutputPriv
+{
+ int type;
+ void *devPrivate;
+} FBDevOutputPriv, *FBDevOutputPrivPtr;
+#define FBDEVOUTPUTPTR(o) ((FBDevOutputPrivPtr)((o)->driver_private))
+
+void LcdOutputInit(ScrnInfoPtr pScrn);
+
+#endif // _FBDEV_OUTPUT_PRIV_H_
+
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "fbdev.h"
+#include "fbdev_output_priv.h"
+#include "fbdev_mode.h"
+
+#include <xf86Crtc.h>
+
+/********************************************************************************************/
+/* Implementation of Output entry points */
+/********************************************************************************************/
+static void lcd_output_create_resources(xf86OutputPtr output)
+{
+}
+
+static void lcd_output_dpms(xf86OutputPtr output, int mode)
+{
+ return;
+}
+
+static void lcd_output_save(xf86OutputPtr output)
+{
+ return;
+}
+
+static void lcd_output_restore(xf86OutputPtr output)
+{
+ return;
+}
+
+static int lcd_output_mode_valid(xf86OutputPtr output, DisplayModePtr mode)
+{
+ FBDevPtr pFBDev = FBDEVPTR(output->scrn);
+
+ if(pFBDev->builtin->HDisplay < mode->HDisplay)
+ return MODE_HSYNC;
+
+ if(pFBDev->builtin->VDisplay < mode->VDisplay)
+ return MODE_VSYNC;
+
+ output->scrn->currentMode = mode;
+
+ return MODE_OK;
+
+}
+
+static Bool lcd_output_mode_fixup(xf86OutputPtr output, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+{
+ return TRUE;
+}
+
+static void lcd_output_prepare(xf86OutputPtr output)
+{
+ return;
+}
+
+static void lcd_output_mode_set(xf86OutputPtr output, DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+{
+ ScrnInfoPtr pScrn = output ->scrn;
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ /* have to set the physical size of the output */
+ output->mm_width = pFBDev->var.width;
+ output->mm_height = pFBDev->var.height;
+ output->conf_monitor->mon_width = pFBDev->var.width;
+ output ->conf_monitor->mon_height = pFBDev->var.height;
+
+ return;
+}
+
+static void lcd_output_commit(xf86OutputPtr output)
+{
+ return;
+}
+
+static xf86OutputStatus lcd_output_detect(xf86OutputPtr output)
+{
+ return XF86OutputStatusConnected;
+}
+
+
+
+/**
+ * Name : lcd_output_get_modes
+ * Input : xf86OutputPtr
+ * Return : DisplayModePtr
+ * Description : Query the device for the modes it provides.
+ This function may also update MonInfo, mm_width, and mm_height.
+ return singly-linked list of modes or NULL if no modes found.
+
+ */
+static int first_time_rotated = TRUE;
+static DisplayModePtr lcd_output_get_modes(xf86OutputPtr output)
+{
+ FBDevPtr pFBDev = FBDEVPTR(output->scrn);
+
+ /* [soolim:20100205] : if there is no mode name in xorg.conf, use the builtin mode */
+ char *preferred_mode;
+ preferred_mode = FBDevCheckPreferredMode(output->scrn, output);
+ if(!preferred_mode)
+ {
+ int HDisplay, VDisplay;
+
+ Bool rotated = (pFBDev->rotate & (RR_Rotate_90|RR_Rotate_270)) != 0;
+
+ if(rotated)
+ {
+ if(first_time_rotated)
+ {
+ memcpy(&pFBDev->builtin_saved, pFBDev->builtin, sizeof(*pFBDev->builtin));
+ VDisplay = pFBDev->builtin->VDisplay;
+ HDisplay = pFBDev->builtin->HDisplay;
+ pFBDev->builtin->HDisplay = VDisplay;
+ pFBDev->builtin->VDisplay = HDisplay;
+ pFBDev->builtin->name = "fake_mode";
+ first_time_rotated = FALSE;
+ }
+ return xf86DuplicateMode(pFBDev->builtin);
+ }
+ else
+ {
+ return xf86DuplicateMode(pFBDev->builtin);
+ }
+ }
+
+ /* [soolim:20100205] : gets the supported modes from framebuffer and makes the list */
+ DisplayModePtr support_modes = NULL;
+
+ if(!pFBDev->support_modes)
+ {
+ support_modes = FBDevGetSupportModes(pFBDev->builtin);
+ if(pFBDev->builtin != NULL)
+ {
+ if(!pFBDev->builtin->next)
+ {
+ support_modes->prev = pFBDev->builtin;
+ pFBDev->builtin->next = support_modes;
+ pFBDev->builtin->prev = NULL;
+ }
+ }
+ else
+ {
+ pFBDev->builtin = support_modes;
+ }
+ }
+
+ return support_modes;
+}
+
+static Bool lcd_output_set_property(xf86OutputPtr output, Atom property,
+ RRPropertyValuePtr value)
+{
+ return TRUE;
+}
+
+static Bool lcd_output_get_property(xf86OutputPtr output, Atom property)
+{
+ return TRUE;
+}
+
+static xf86CrtcPtr lcd_output_crtc_get(xf86OutputPtr output)
+{
+ return 0;
+}
+
+static void lcd_output_destroy(xf86OutputPtr output)
+{
+ return;
+}
+
+
+/* output funcs */
+static const xf86OutputFuncsRec lcd_output_funcs =
+{
+ .create_resources = lcd_output_create_resources,
+ .destroy = lcd_output_destroy,
+ .dpms = lcd_output_dpms,
+ .save = lcd_output_save,
+ .restore = lcd_output_restore,
+ .mode_valid = lcd_output_mode_valid,
+
+ .mode_fixup = lcd_output_mode_fixup,
+ .prepare = lcd_output_prepare,
+ .mode_set = lcd_output_mode_set,
+ .commit = lcd_output_commit,
+ .detect = lcd_output_detect,
+ .get_modes = lcd_output_get_modes,
+#ifdef RANDR_12_INTERFACE
+ .set_property = lcd_output_set_property,
+#endif
+#ifdef RANDR_13_INTERFACE /* not a typo */
+ .get_property = lcd_output_get_property,
+#endif
+#ifdef RANDR_GET_CRTC_INTERFACE
+ .get_crtc = lcd_output_crtc_get,
+#endif
+};
+
+void LcdOutputInit(ScrnInfoPtr pScrn)
+{
+ xf86OutputPtr output;
+ FBDevOutputPrivPtr lcd_output;
+
+ output = xf86OutputCreate (pScrn, &lcd_output_funcs, "LCD");
+ if (!output)
+ return;
+ lcd_output = xnfcalloc (sizeof (FBDevOutputPriv), 1);
+ if (!lcd_output)
+ {
+ xf86OutputDestroy (output);
+ return;
+ }
+
+ output->driver_private = lcd_output;
+ output->interlaceAllowed = FALSE;
+ output->doubleScanAllowed = FALSE;
+
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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
+
+/* all driver need this */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "fb.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+#include "colormapst.h"
+#include "xf86cmap.h"
+#include "xf86xv.h"
+#include "xf86Crtc.h"
+
+#include "fbdev.h"
+#include "fbdevhw.h"
+#include "fbdev_hw.h"
+#include "fbdev_video.h"
+#include "fbdev_crtcconfig.h"
+#include "fbdev_dpms.h"
+
+#include <string.h>
+#include <sys/ioctl.h>
+#include <linux/fb.h>
+
+/* prototypes */
+static const OptionInfoRec * FBDevAvailableOptions(int chipid, int busid);
+static void FBDevIdentify(int flags);
+static Bool FBDevProbe(DriverPtr drv, int flags);
+static Bool FBDevPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool FBDevScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv);
+static Bool FBDevEnterVT(int scrnIndex, int flags);
+static void FBDevLeaveVT(int scrnIndex, int flags);
+static Bool FBDevCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static void FBDevSaveCurrent(ScrnInfoPtr pScrn);
+
+/* This DriverRec must be defined in the driver for Xserver to load this driver */
+_X_EXPORT DriverRec FBDEV =
+{
+ FBDEV_VERSION,
+ FBDEV_DRIVER_NAME,
+ FBDevIdentify,
+ FBDevProbe,
+ FBDevAvailableOptions,
+ NULL,
+ 0,
+ NULL,
+};
+
+/* Supported "chipsets" */
+static SymTabRec FBDevChipsets[] =
+{
+ {-1, NULL }
+};
+
+/* Supported options */
+typedef enum
+{
+ OPTION_SWCURSOR,
+ OPTION_FBDEV
+} FBDevOpts;
+
+static const OptionInfoRec FBDevOptions[] =
+{
+ { OPTION_SWCURSOR, "swcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_FBDEV, "fbdev", OPTV_STRING, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+/* -------------------------------------------------------------------- */
+
+
+#ifdef XFree86LOADER
+
+MODULESETUPPROTO(FBDevSetup);
+
+static XF86ModuleVersionInfo FBDevVersRec =
+{
+ "emulfb",
+ 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 emulfbModuleData = { &FBDevVersRec, FBDevSetup, NULL };
+
+pointer
+FBDevSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone)
+ {
+ setupDone = TRUE;
+ xf86AddDriver(&FBDEV, module, HaveDriverFuncs);
+ return (pointer)1;
+ }
+ else
+ {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+FBDevGetRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(FBDevRec), 1);
+ return TRUE;
+}
+
+static void
+FBDevFreeRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn->driverPrivate == NULL)
+ return;
+ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+}
+
+/* -------------------------------------------------------------------- */
+
+static const OptionInfoRec *
+FBDevAvailableOptions(int chipid, int busid)
+{
+ return FBDevOptions;
+}
+
+static void
+FBDevIdentify(int flags)
+{
+ xf86PrintChipsets(FBDEV_NAME, "driver for framebuffer", FBDevChipsets);
+}
+
+/*
+ * Probing the device with the device node, this probing depend on the specific hw.
+ * This function just verify whether the display hw is avaliable or not.
+ */
+static Bool
+FBDevHWProbe(struct pci_device * pPci, char *device,char **namep)
+{
+ return fbdevHWProbe(pPci,device,namep);
+}
+
+/* The purpose of this function is to identify all instances of hardware supported
+ * by the driver. The probe must find the active device sections that match the driver
+ * by calling xf86MatchDevice().
+ */
+static Bool
+FBDevProbe(DriverPtr drv, int flags)
+{
+ int i;
+ ScrnInfoPtr pScrn;
+ GDevPtr *devSections;
+ int numDevSections;
+ char *dev;
+ int entity;
+ Bool foundScreen = FALSE;
+
+ /* For now, just bail out for PROBE_DETECT. */
+ if (flags & PROBE_DETECT)
+ return FALSE;
+
+ if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0)
+ return FALSE;
+
+ if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
+ return FALSE;
+
+ for (i = 0; i < numDevSections; i++)
+ {
+ dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
+ if (FBDevHWProbe(NULL,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 = FBDEV_VERSION;
+ pScrn->driverName = FBDEV_DRIVER_NAME;
+ pScrn->name = FBDEV_NAME;
+ pScrn->Probe = FBDevProbe;
+ pScrn->PreInit = FBDevPreInit;
+ pScrn->ScreenInit = FBDevScreenInit;
+ pScrn->SwitchMode = fbdevHWSwitchModeWeak();
+ pScrn->AdjustFrame = fbdevHWAdjustFrameWeak();
+ pScrn->EnterVT = FBDevEnterVT;
+ pScrn->LeaveVT = FBDevLeaveVT;
+ pScrn->ValidMode = fbdevHWValidModeWeak();
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO
+ ,"using %s\n", dev ? dev : "default device");
+ }
+ }
+ }
+ free(devSections);
+
+ return foundScreen;
+}
+
+/*
+ * Return the default depth and bits per pixel.
+ * Determine the depth and the bpp supported by hw with the hw color format.
+ */
+static int
+FBDevGetDefaultDepth(ScrnInfoPtr pScrn, int *bitsPerPixel)
+{
+ int defaultDepth;
+
+ /* finding out the valid default_depth */
+ defaultDepth = fbdevHWGetDepth(pScrn,bitsPerPixel);
+
+ /* the default depth is not more than 24 */
+ defaultDepth = ((*bitsPerPixel)==32)?24:*bitsPerPixel;
+
+ return defaultDepth;
+}
+
+/*
+ * Initialize the device Probing the device with the device node,
+ * this probing depend on the specific hw.
+ * This function just verify whether the display hw is avaliable or not.
+ */
+static Bool
+FBDevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
+{
+ /* open device : open the framebuffer device */
+ if (!fbdevHWInit(pScrn, NULL, device))
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * DeInitialize the hw
+ */
+static void
+FBDevHWDeInit(ScrnInfoPtr pScrn)
+{
+ /* close the fd of the fb device ??? */
+
+ return;
+}
+
+/*
+ * Check the driver option.
+ * Set the option flags to the driver private
+ */
+static void
+FBDevCheckDriverOptions(ScrnInfoPtr pScrn)
+{
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ /* sw cursor */
+ if (xf86ReturnOptValBool(pFBDev->Options, OPTION_SWCURSOR, FALSE))
+ pFBDev->bSWCursorEnbled = TRUE;
+}
+
+
+
+/*
+ * This is called before ScreenInit to probe the screen configuration.
+ * The main tasks to do in this funtion are probing, module loading, option handling,
+ * card mapping, and Crtcs setup.
+ */
+static Bool
+FBDevPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ FBDevPtr pFBDev;
+ int default_depth, fbbpp;
+ char *path;
+ Gamma defualt_gamma = {0.0, 0.0, 0.0};
+ rgb default_weight = { 0, 0, 0 };
+ int flag24;
+
+ 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;
+
+ /* allocate private */
+ FBDevGetRec(pScrn);
+ pFBDev = FBDEVPTR(pScrn);
+
+ pFBDev->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+ /* can set the path with fbdev option */
+ path = xf86FindOptionValue(pFBDev->pEnt->device->options, "fbdev");
+
+ /* Init HW */
+ if(!FBDevHWInit(pScrn,NULL,path))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_Error
+ , "fail to initialize hardware\n");
+ goto bail1;
+ }
+
+ /* finding out the valid default_depth */
+ default_depth = FBDevGetDefaultDepth(pScrn,&fbbpp);
+
+ /* set the depth and the bpp to pScrn */
+ flag24 = Support24bppFb | Support32bppFb;
+ if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp, flag24))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR
+ , "fail to find the depth\n");
+ goto bail1;
+ }
+ xf86PrintDepthBpp(pScrn); /* just print out the depth and the bpp */
+
+ /* color weight */
+ if (!xf86SetWeight(pScrn, default_weight, default_weight))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR
+ , "fail to set the color weight of RGB\n");
+ goto bail1;
+ }
+
+ /* visual init, make a TrueColor, -1 */
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR
+ , "fail to initialize the default visual\n");
+ goto bail1;
+ }
+
+ /* set gamma */
+ if (!xf86SetGamma(pScrn,defualt_gamma))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR
+ , "fail to set the gamma\n");
+ goto bail1;
+ }
+
+ pScrn->progClock = TRUE;
+ pScrn->rgbBits = 8;
+ pScrn->chipset = "fbdev";
+ pScrn->videoRam = fbdevHWGetVidmem(pScrn);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO
+ , "hardware: %s (video memory: %dkB)\n"
+ , fbdevHWGetName(pScrn)
+ , pScrn->videoRam/1024);
+
+ /* Collect all the option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+
+ /*
+ * Process the options based on the information S5POptions.
+ * The results are written to pS5P->Options. If all the options
+ * processing is done within this fuction a local variable "options"
+ * can be used instead of pS5P->Options
+ */
+ if (!(pFBDev->Options = malloc(sizeof(FBDevOptions))))
+ goto bail1;
+ memcpy(pFBDev->Options, FBDevOptions, sizeof(FBDevOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pFBDev->pEnt->device->options, pFBDev->Options);
+
+ /* Check with the driver options */
+ FBDevCheckDriverOptions(pScrn);
+
+ /* Set the Crtc, the default Output, and the current Mode */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO
+ , "checking modes against framebuffer device and creating crtc and ouput...\n");
+ if(!FBDevCrtcConfigInit(pScrn))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR
+ , "Fail to init the CrtcConfig\n");
+ goto bail1;
+ }
+ FBDevSaveCurrent(pScrn);
+
+ /* TODO::soolim:: re-confirm this condition */
+ if(pScrn->currentMode->HDisplay == pFBDev->var.xres_virtual
+ && pScrn->currentMode->VDisplay <= pFBDev->var.yres_virtual)
+ {
+ pScrn->virtualX = pFBDev->var.xres_virtual;
+ pScrn->virtualY = pFBDev->var.yres_virtual;
+ }
+ else
+ {
+ pScrn->virtualX = pScrn->currentMode->HDisplay;
+ pScrn->virtualY = pScrn->currentMode->VDisplay;
+ }
+ pScrn->displayWidth = pScrn->virtualX;
+ xf86PrintModes(pScrn); /* just print the current mode */
+
+ /* Set display resolution */
+ if(pFBDev->var.width && pFBDev->var.height)
+ {
+ pScrn->monitor->widthmm = pFBDev->var.width;
+ pScrn->monitor->heightmm = pFBDev->var.height;
+ }
+ xf86SetDpi(pScrn, 0, 0);
+
+ /* Load fb submodule */
+ if (!xf86LoadSubModule(pScrn, "fb"))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "fail to load fb module\n");
+ goto bail1;
+ }
+
+ return TRUE;
+
+bail1:
+ FBDevFreeRec(pScrn);
+ FBDevHWDeInit(pScrn);
+ return FALSE;
+}
+
+static void
+FBDevAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ fbdevHWAdjustFrame(scrnIndex,x,y,flags);
+}
+
+
+/* Save the hw information */
+static void
+FBDevSave(ScrnInfoPtr pScrn)
+{
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ FBDevGetVarScreenInfo(fbdevHWGetFD(pScrn), &pFBDev->saved_var);
+}
+
+/* Restore the hw information */
+static void
+FBDevRestore(ScrnInfoPtr pScrn)
+{
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ FBDevSetVarScreenInfo(fbdevHWGetFD(pScrn), &pFBDev->saved_var);
+}
+
+/* Save the current hw information */
+static void
+FBDevSaveCurrent(ScrnInfoPtr pScrn)
+{
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ FBDevGetVarScreenInfo(fbdevHWGetFD(pScrn), &pFBDev->var);
+ FBDevGetFixScreenInfo(fbdevHWGetFD(pScrn), &pFBDev->fix);
+}
+
+static Bool
+FBDevModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ if (!fbdevHWModeInit(pScrn, mode))
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Get the address of the framebuffer */
+static unsigned char *
+FBDevGetFbAddr(ScrnInfoPtr pScrn)
+{
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+ return pFBDev->fbstart;
+}
+
+static Bool
+FBDevScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+ VisualPtr visual;
+ int init_picture = 0;
+ unsigned char * pFbAddr;
+ pFBDev->rotate = RR_Rotate_0;
+ Bool rotated = (pFBDev->rotate & (RR_Rotate_90|RR_Rotate_270)) != 0;
+
+ xf86DrvMsg(scrnIndex,X_INFO,
+ "Infomation of Visual is \n\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n"
+ "\tmask: %x,%x,%x, offset: %d,%d,%d\n",
+ pScrn->bitsPerPixel,
+ pScrn->depth,
+ xf86GetVisualName(pScrn->defaultVisual),
+ (unsigned int) pScrn->mask.red,
+ (unsigned int) pScrn->mask.green,
+ (unsigned int) pScrn->mask.blue,
+ (int)pScrn->offset.red,
+ (int)pScrn->offset.green,
+ (int)pScrn->offset.blue);
+
+ pFBDev->fbmem = fbdevHWMapVidmem(pScrn); /* mmap memory pointer */
+ if (!pFBDev->fbmem)
+ {
+ xf86DrvMsg(scrnIndex,X_ERROR
+ ,"mapping of video memory failed\n");
+ return FALSE;
+ }
+ pFBDev->fboff = fbdevHWLinearOffset(pScrn);
+
+ /* save fb information */
+ FBDevSave(pScrn);
+
+ /* set mode and set fb info */
+ DisplayModePtr tmpMode;
+
+ if(rotated)
+ tmpMode = &pFBDev->builtin_saved;
+ else
+ tmpMode = pScrn->currentMode;
+
+ if (!FBDevModeInit(pScrn, tmpMode))
+ {
+ xf86DrvMsg(scrnIndex,X_ERROR
+ ,"mode initialization failed\n");
+ return FALSE;
+ }
+
+ fbdevHWSaveScreen(pScreen, SCREEN_SAVER_ON);
+ FBDevAdjustFrame(scrnIndex,0,0,0);
+
+ FBDevSaveCurrent(pScrn);
+
+ /* mi layer */
+ miClearVisualTypes();
+ 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;
+ }
+ if (!miSetPixmapDepths())
+ {
+ xf86DrvMsg(scrnIndex,X_ERROR
+ ,"pixmap depth setup failed\n");
+ return FALSE;
+ }
+
+ /* set the starting point of the framebuffer */
+ pFBDev->fbstart = pFBDev->fbmem + pFBDev->fboff;
+
+ /* Get the screen address */
+ pFbAddr = FBDevGetFbAddr(pScrn);
+
+ switch (pScrn->bitsPerPixel)
+ {
+ case 16:
+ case 24:
+ case 32:
+ if(! fbScreenInit(pScreen, pFbAddr,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX, /*Pixel width for framebuffer*/
+ pScrn->bitsPerPixel))
+ return FALSE;
+
+ init_picture = 1;
+
+ break;
+ default:
+ xf86DrvMsg(scrnIndex, X_ERROR
+ , "internal error: invalid number of bits per pixel (%d) encountered\n"
+ , pScrn->bitsPerPixel);
+ break;
+ }
+
+ 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");
+
+ /* XVideo Initiailization here */
+#ifdef XV
+ if (!fbdevVideoInit(pScreen))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "XVideo extention initialization failed\n");
+#endif
+
+ xf86SetBlackWhitePixels(pScreen);
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+
+ /* Check whether the SWCURSOR option is enbled */
+ if(pFBDev->bSWCursorEnbled)
+ {
+ /* use software cursor */
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+ }
+ else
+ {
+ /* use dummy hw_cursro instead of sw_cursor */
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO
+ , "Initializing HW Cursor\n");
+
+ if(!xf86_cursors_init(pScreen, SEC_CURSOR_W, SEC_CURSOR_H, (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+ HARDWARE_CURSOR_INVERT_MASK |
+ HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+ HARDWARE_CURSOR_ARGB)))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR
+ , "Hardware cursor initialization failed\n");
+ }
+ }
+
+ /* crtc init */
+ if (!xf86CrtcScreenInit(pScreen))
+ return FALSE;
+
+ /* set the desire mode : set the mode to xf86crtc here */
+ xf86SetDesiredModes(pScrn);
+
+ /* colormap */
+ if (!miCreateDefColormap(pScreen))
+ {
+ xf86DrvMsg(scrnIndex, X_ERROR
+ , "internal error: miCreateDefColormap failed \n");
+ return FALSE;
+ }
+
+ if(!xf86HandleColormaps(pScreen, 256, 8, fbdevHWLoadPaletteWeak(), NULL, CMAP_PALETTED_TRUECOLOR))
+ return FALSE;
+
+ xf86DPMSInit(pScreen, FBDevDPMSSet(), 0);
+ pScreen->SaveScreen = FBDevSaveScreen();
+ pFBDev->isLcdOff = FALSE;
+
+ /* Wrap the current CloseScreen function */
+ pFBDev->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = FBDevCloseScreen;
+
+ return TRUE;
+}
+
+
+static Bool
+FBDevEnterVT(int scrnIndex, int flags)
+{
+
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO
+ , "EnterVT::Hardware state at EnterVT:\n");
+ return TRUE;
+}
+
+static void
+FBDevLeaveVT(int scrnIndex, int flags)
+{
+
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO
+ , "LeaveVT::Hardware state at LeaveVT:\n");
+}
+
+static Bool
+FBDevCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ FBDevRestore(pScrn);
+
+ fbdevHWUnmapVidmem(pScrn);
+ pScrn->vtSema = FALSE;
+
+ if(!pFBDev->bLockScreen)
+ FBDevRestore(pScrn);
+ else
+ ErrorF("Screen closed but LCD was locked\n");
+
+ FBDevHWDeInit(pScrn);
+
+ pScreen->CreateScreenResources = pFBDev->CreateScreenResources;
+ pScreen->CloseScreen = pFBDev->CloseScreen;
+
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+}
+
+
+
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 FBDEV_H
+#define FBDEV_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "fbdevhw.h"
+#include "xf86xv.h"
+#include <linux/fb.h>
+
+#define PAGE_SIZE 4096
+
+#define FBDEV_VERSION 1000 /* the version of the driver */
+#define FBDEV_NAME "SEC" /* the name used to prefix messages */
+#define FBDEV_DRIVER_NAME "emulfb" /* the driver name as used in config file.
+ * This name should match the name of the driver module binary
+ * In this driver, the name of the driver libary module is emulfb_drv.so.
+ */
+#define SWAPINT(i, j) \
+{ int _t = i; i = j; j = _t; }
+
+#define SEC_CURSOR_W 64
+#define SEC_CURSOR_H 64
+
+/* FBDev driver private data structure to hold the driver's screen-specific data */
+typedef struct {
+ unsigned char *fbstart; /* start memory point of framebuffer: (fbmem + fboff) */
+ unsigned char *fbmem; /* mmap memory pointer of framebuffer */
+ int fboff; /* fb offset */
+ int lineLength;
+ CloseScreenProcPtr CloseScreen;
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ void (*PointerMoved)(int index, int x, int y);
+ EntityInfoPtr pEnt;
+
+ /* driver options */
+ OptionInfoPtr Options;
+ Bool bSWCursorEnbled; /* software cursor enabled */
+ int rotate;
+
+ /* saved video mode */
+ struct fb_var_screeninfo saved_var;
+
+ /* Current information of Framebuffer */
+ struct fb_var_screeninfo var;
+ struct fb_fix_screeninfo fix;
+
+ /* mode infos */
+ DisplayModePtr builtin;
+ DisplayModeRec builtin_saved; /* original mode to send the fake mode when the screen rotates */
+ DisplayModePtr support_modes;
+
+ /* xv */
+#ifdef XV
+ XF86VideoAdaptorPtr pAdaptor;
+ void **v4l2_owner;
+ int v4l2_num;
+ Bool bFbAlphaEnabled;
+#endif
+
+ Bool bLockScreen;
+
+ /* dpms - flag for the control of lcd onoff*/
+ Bool isLcdOff;
+
+ /* Cursor */
+ Bool enableCursor;
+} FBDevRec, *FBDevPtr;
+#define FBDEVPTR(p) ((FBDevPtr)((p)->driverPrivate))
+
+#endif //FBDEV_H
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "fbdev.h"
+#include <linux/fb.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include "fbdev.h"
+#include "fbdevhw.h"
+#include "fbdev_hw.h"
+#include <X11/extensions/dpmsconst.h>
+
+#include "misc.h"
+#include "fbdev_dpms.h"
+
+static void
+fbdevDPMSSetFunc(ScrnInfoPtr pScrn, int mode, int flags)
+{
+ FBDevPtr pFBDev = FBDEVPTR(pScrn);
+
+ switch(DPMSPowerLevel)
+ {
+ case DPMSModeOn:
+ case DPMSModeSuspend:
+ break;
+ case DPMSModeStandby:
+ if(pFBDev->isLcdOff == FALSE) break;
+
+ /* lcd on */
+ if (-1 == ioctl(fbdevHWGetFD(pScrn), FBIOBLANK, FB_BLANK_UNBLANK))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOBLANK: %s\n", strerror(errno));
+ }
+
+ pFBDev->isLcdOff = FALSE;
+ break;
+ case DPMSModeOff:
+ if(pFBDev->isLcdOff == TRUE) break;
+
+ /* lcd off */
+ if (-1 == ioctl(fbdevHWGetFD(pScrn), FBIOBLANK, FB_BLANK_POWERDOWN))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOBLANK: %s\n", strerror(errno));
+ }
+
+ pFBDev->isLcdOff = TRUE;
+ break;
+ default:
+ return;
+ }
+}
+
+xf86DPMSSetProc*
+FBDevDPMSSet(void)
+{
+ return fbdevDPMSSetFunc;
+}
+
+static Bool first_savescreen = FALSE;
+
+static Bool
+fbdevSaveScreenFunc(ScreenPtr pScreen, int mode)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if(!first_savescreen)
+ {
+ first_savescreen = TRUE;
+ if (-1 == ioctl(fbdevHWGetFD(pScrn), FBIOBLANK, (void *)(0)))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOBLANK: %s\n", strerror(errno));
+ }
+ }
+
+ return TRUE;
+}
+
+
+SaveScreenProcPtr
+FBDevSaveScreen(void)
+{
+ return fbdevSaveScreenFunc;
+}
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 FBDEV_DPMS_H
+#define FBDEV_DPMS_H
+
+xf86DPMSSetProc* FBDevDPMSSet(void);
+SaveScreenProcPtr FBDevSaveScreen(void);
+
+#endif /* FBDEV_DPMS_H */
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "fbdev.h"
+#include "fbdev_hw.h"
+
+void
+FBDevGetVarScreenInfo(int fd, struct fb_var_screeninfo *fbVarInfo)
+{
+ if (0 != ioctl(fd,FBIOGET_VSCREENINFO, (void*)fbVarInfo))
+ fprintf(stderr, "Error : fail to get FBIOGET_VSCREENINFO\n");
+}
+
+void
+FBDevSetVarScreenInfo(int fd, struct fb_var_screeninfo *fbVarInfo)
+{
+ if (0 != ioctl(fd,FBIOPUT_VSCREENINFO,(void*)fbVarInfo))
+ fprintf(stderr, "Error : fail to get FBIOPUT_VSCREENINFO\n");
+}
+
+void
+FBDevGetFixScreenInfo(int fd, struct fb_fix_screeninfo *fbFixInfo)
+{
+ if (0 != ioctl(fd,FBIOGET_FSCREENINFO,(void*)fbFixInfo))
+ fprintf(stderr, "Error : fail to get FBIOGET_FSCREENINFO\n");
+}
+
+Bool
+FBDevScreenAlphaInit(int fd)
+{
+ struct fb_var_screeninfo var;
+ int ret;
+
+ ret = ioctl(fd, FBIOGET_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ return FALSE;
+ }
+
+ if (var.bits_per_pixel != 32)
+ {
+ return FALSE;
+ }
+ var.transp.length = 8;
+ var.activate = FB_ACTIVATE_FORCE;
+ ret = ioctl(fd, FBIOPUT_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+FBDevScreenAlphaDeinit(int fd)
+{
+ struct fb_var_screeninfo var;
+ int ret;
+
+ ret = ioctl(fd, FBIOGET_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ return FALSE;
+ }
+
+ var.transp.length = 0;
+ ret = ioctl(fd, FBIOPUT_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#include <sys/utsname.h>
+
+/* activate fb */
+Bool
+FBDevActivateFB(int fd)
+{
+ struct fb_var_screeninfo var;
+ int ret;
+
+ ret = ioctl(fd, FBIOGET_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ ErrorF("failed to get fb_var\n");
+ return FALSE;
+ }
+
+ var.activate = FB_ACTIVATE_FORCE;
+
+ ret = ioctl (fd, FBIOPUT_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ ErrorF("failed to set fb_var.activate\n");
+ return FALSE;
+ }
+
+ ret = ioctl (fd, FBIOBLANK, FB_BLANK_UNBLANK);
+ if (ret < 0)
+ {
+ ErrorF("failed to set FBIOBLANK : FB_BLANK_UNBLANK\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* deactivate fb3 */
+Bool
+FBDevDeActivateFB(int fd)
+{
+ int ret;
+
+ ret = ioctl (fd, FBIOBLANK, FB_BLANK_POWERDOWN);
+ if (ret < 0)
+ {
+ ErrorF("failed to set FBIOBLANK : FB_BLANK_POWERDOWN\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+FBDevSetBaseFrameBuffer(int fd)
+{
+ struct fb_var_screeninfo var;
+ int ret;
+
+ ret = ioctl(fd, FBIOGET_VSCREENINFO, &var);
+ if (ret < 0)
+ {
+ return FALSE;
+ }
+
+ var.yoffset = 0;
+ ret = ioctl (fd, FBIOPAN_DISPLAY,&var);
+ if (ret < 0)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+void
+FBDevHWPanDisplay(int fd, int x, int y)
+{
+ struct fb_var_screeninfo var;
+ int ret;
+
+ ret = ioctl(fd, FBIOGET_VSCREENINFO, &var);
+ if(ret < 0)
+ {
+ return;
+ }
+
+ var.xoffset = x;
+ var.yoffset = y;
+ ret = ioctl(fd, FBIOPAN_DISPLAY, &var);
+ if(ret < 0)
+ {
+ return;
+ }
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 FBDEV_HW_H
+#define FBDEV_HW_H
+
+#include <linux/fb.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+void FBDevGetVarScreenInfo(int fd, struct fb_var_screeninfo *fbVarInfo);
+void FBDevSetVarScreenInfo(int fd, struct fb_var_screeninfo *fbVarInfo);
+void FBDevGetFixScreenInfo(int fd, struct fb_fix_screeninfo *fbFixInfo);
+
+Bool FBDevScreenAlphaInit(int fd);
+Bool FBDevScreenAlphaDeinit(int fd);
+Bool FBDevActivateFB(int fd);
+Bool FBDevDeActivateFB(int fd);
+Bool FBDevSetBaseFrameBuffer(int fd);
+void FBDevHWPanDisplay(int fd, int x, int y);
+
+#endif //FBDEV_HW_H
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "fbdev_util.h"
+#include "fbdev_pixman.h"
+
+int
+fbdev_pixman_convert_image (int xres,
+ int yres,
+ unsigned char *srcbuf,
+ unsigned char *dstbuf,
+ pixman_format_code_t src_format,
+ pixman_format_code_t dst_format,
+ xRectangle *img,
+ xRectangle *pixmap,
+ xRectangle *draw,
+ xRectangle *src,
+ xRectangle *dst,
+ RegionPtr clip_region,
+ int rotate,
+ int hflip,
+ int vflip)
+{
+ pixman_image_t *src_img;
+ pixman_image_t *dst_img;
+ struct pixman_f_transform ft;
+ pixman_transform_t transform;
+ int src_stride, dst_stride;
+ int src_bpp;
+ int dst_bpp;
+ double scale_x, scale_y;
+ pixman_op_t op;
+ int rotate_step;
+ int ret = FALSE;
+
+ return_val_if_fail (srcbuf != NULL, FALSE);
+ return_val_if_fail (dstbuf != NULL, FALSE);
+ return_val_if_fail (img != NULL, FALSE);
+ return_val_if_fail (pixmap != NULL, FALSE);
+ return_val_if_fail (draw != NULL, FALSE);
+ return_val_if_fail (src != NULL, FALSE);
+ return_val_if_fail (dst != NULL, FALSE);
+ return_val_if_fail (rotate <= 360 && rotate >= -360, FALSE);
+
+ op = PIXMAN_OP_SRC;
+
+ src_bpp = PIXMAN_FORMAT_BPP (src_format) / 8;
+ return_val_if_fail (src_bpp > 0, FALSE);
+
+ dst_bpp = PIXMAN_FORMAT_BPP (dst_format) / 8;
+ return_val_if_fail (dst_bpp > 0, FALSE);
+
+ rotate_step = (rotate + 360) / 90 % 4;
+
+ src_stride = img->width * src_bpp;
+ dst_stride = pixmap->width * dst_bpp;
+
+ src_img = pixman_image_create_bits (src_format, img->width, img->height, (uint32_t*)srcbuf, src_stride);
+ dst_img = pixman_image_create_bits (dst_format, pixmap->width, pixmap->height, (uint32_t*)dstbuf, dst_stride);
+
+ goto_if_fail (src_img != NULL, CANT_CONVERT);
+ goto_if_fail (dst_img != NULL, CANT_CONVERT);
+
+ pixman_f_transform_init_identity (&ft);
+
+ if (hflip)
+ {
+ pixman_f_transform_scale (&ft, NULL, 1, -1);
+ pixman_f_transform_translate (&ft, NULL, 0, (rotate_step%2)?draw->width:draw->height);
+ }
+
+ if (vflip)
+ {
+ pixman_f_transform_scale (&ft, NULL, -1, 1);
+ pixman_f_transform_translate (&ft, NULL, (rotate_step%2)?draw->height:draw->width, 0);
+ }
+
+ if (rotate_step > 0)
+ {
+ int c, s, tx = 0, ty = 0;
+ switch (rotate_step)
+ {
+ case 1:
+ /* 270 degrees */
+ c = 0;
+ s = -1;
+ ty = draw->width;
+ break;
+ case 2:
+ /* 180 degrees */
+ c = -1;
+ s = 0;
+ tx = draw->width;
+ ty = draw->height;
+ break;
+ case 3:
+ /* 90 degrees */
+ c = 0;
+ s = 1;
+ tx = draw->height;
+ break;
+ default:
+ /* 0 degrees */
+ c = 0;
+ s = 0;
+ break;
+ }
+ pixman_f_transform_rotate (&ft, NULL, c, s);
+ pixman_f_transform_translate (&ft, NULL, tx, ty);
+ }
+
+ if (rotate_step % 2 == 0)
+ {
+ scale_x = (double)src->width / dst->width;
+ scale_y = (double)src->height / dst->height;
+ }
+ else
+ {
+ scale_x = (double)src->width / dst->height;
+ scale_y = (double)src->height / dst->width;
+ }
+
+ pixman_f_transform_scale (&ft, NULL, scale_x, scale_y);
+ pixman_f_transform_translate (&ft, NULL, src->x, src->y);
+
+ pixman_transform_from_pixman_f_transform (&transform, &ft);
+ pixman_image_set_transform (src_img, &transform);
+
+ pixman_image_composite (op, src_img, NULL, dst_img,
+ 0, 0, 0, 0, dst->x, dst->y, dst->width, dst->height);
+
+ ret = TRUE;
+
+CANT_CONVERT:
+ if (src_img)
+ pixman_image_unref (src_img);
+ if (dst_img)
+ pixman_image_unref (dst_img);
+
+ return ret;
+}
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: Boram Park <boram1288.park@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 __FBDEV_PIXMAN_H__
+#define __FBDEV_PIXMAN_H__
+
+#include <sys/types.h>
+#include <X11/Xdefs.h>
+#include <fbdevhw.h>
+
+#include <pixman.h>
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE (!FALSE)
+#endif
+
+#ifndef NULL
+#define NULL (void*)0
+#endif
+
+int
+fbdev_pixman_convert_image (int xres,
+ int yres,
+ unsigned char *srcbuf,
+ unsigned char *dstbuf,
+ pixman_format_code_t src_format,
+ pixman_format_code_t dst_format,
+ xRectangle *img,
+ xRectangle *pixmap,
+ xRectangle *draw,
+ xRectangle *src,
+ xRectangle *dst,
+ RegionPtr clip_region,
+ int rotate,
+ int hflip,
+ int vflip);
+
+#endif /* __FBDEV_PIXMAN_H__ */
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+
+#include "X11/XWDFile.h"
+#include "fbdev.h"
+#include "fbdev_util.h"
+
+int fbdev_util_dump_raw(const char * file, const void * data, int width, int height)
+{
+ unsigned int * blocks;
+
+ FILE * fp = fopen(file, "w+");
+ if (fp == NULL)
+ return 0;
+
+ blocks = (unsigned int *) data;
+ fwrite(blocks, 4, width*height, fp);
+
+ fclose(fp);
+
+ return 1;
+}
+
+#ifndef RR_Rotate_All
+#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
+#endif
+
+int fbdev_util_degree_to_rotate(int degree)
+{
+ int rotate;
+
+ switch(degree)
+ {
+ case 0:
+ rotate = RR_Rotate_0;
+ break;
+ case 90:
+ rotate = RR_Rotate_90;
+ break;
+ case 180:
+ rotate = RR_Rotate_180;
+ break;
+ case 270:
+ rotate = RR_Rotate_270;
+ break;
+ default:
+ rotate = 0; /* ERROR */
+ break;
+ }
+
+ return rotate;
+}
+
+int fbdev_util_rotate_to_degree(int rotate)
+{
+ int degree;
+
+ switch(rotate & RR_Rotate_All)
+ {
+ case RR_Rotate_0:
+ degree = 0;
+ break;
+ case RR_Rotate_90:
+ degree = 90;
+ break;
+ case RR_Rotate_180:
+ degree = 180;
+ break;
+ case RR_Rotate_270:
+ degree = 270;
+ break;
+ default:
+ degree = -1; /* ERROR */
+ break;
+ }
+
+ return degree;
+}
+
+static int
+_fbdev_util_rotate_to_int(int rot)
+{
+ switch(rot & RR_Rotate_All)
+ {
+ case RR_Rotate_0:
+ return 0;
+ case RR_Rotate_90:
+ return 1;
+ case RR_Rotate_180:
+ return 2;
+ case RR_Rotate_270:
+ return 3;
+ }
+
+ return 0;
+}
+
+int fbdev_util_rotate_add(int rot_a, int rot_b)
+{
+ int a = _fbdev_util_rotate_to_int(rot_a);
+ int b = _fbdev_util_rotate_to_int(rot_b);
+
+ return (int)((1 << ((a+b)%4))&RR_Rotate_All);
+}
+
+const PropertyPtr
+fbdev_util_get_window_property(WindowPtr pWin, const char* prop_name)
+{
+ int rc;
+ Mask prop_mode = DixReadAccess;
+ Atom property;
+ PropertyPtr pProp;
+
+ property = MakeAtom(prop_name, strlen(prop_name), FALSE);
+ if(property == None)
+ return NULL;
+
+ rc = dixLookupProperty(&pProp, pWin, property, serverClient, prop_mode);
+ if (rc == Success && pProp->data)
+ {
+ return pProp;
+ }
+
+ return NULL;
+}
+
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "property.h"
+
+#define return_if_fail(cond) {if (!(cond)) { ErrorF ("%s : '%s' failed.\n", __FUNCTION__, #cond); return; }}
+#define return_val_if_fail(cond, val) {if (!(cond)) { ErrorF ("%s : '%s' failed.\n", __FUNCTION__, #cond); return val; }}
+#define goto_if_fail(cond, dst) {if (!(cond)) { ErrorF ("%s : '%s' failed.\n", __FUNCTION__, #cond); goto dst; }}
+
+int fbdev_util_degree_to_rotate(int degree);
+int fbdev_util_rotate_to_degree(int rotate);
+int fbdev_util_rotate_add(int rot_a, int rot_b);
+
+const PropertyPtr fbdev_util_get_window_property(WindowPtr pWin, const char* prop_name);
+
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <linux/vt.h>
+#include <linux/videodev2.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <poll.h>
+#include <signal.h>
+
+#include "v4l2config.h"
+#include "v4l2_output_api.h"
+
+#ifdef __ASSEMBLY__
+#define _AC(X,Y) X
+#define _AT(T,X) X
+#else
+#define __AC(X,Y) (X##Y)
+#define _AC(X,Y) __AC(X,Y)
+#define _AT(T,X) ((T)(X))
+#endif
+
+#define PAGE_SHIFT 12
+#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
+
+int v4l2_close_fd(int fd)
+{
+ int ret_val;
+ if (-1 != fd)
+ {
+ ret_val = close(fd);
+
+ if(ret_val < 0)
+ {
+ fprintf(stderr,"Cannot close (%d)'%d' : (%s)\n", fd, ret_val, strerror(errno));
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int v4l2_set_src(int fd, struct v4l2_rect *src, struct v4l2_rect *crop_rect, unsigned int pixel_format)
+{
+ return 0;
+}
+
+int v4l2_set_buf(int fd, int num_buf, struct v4l2_dst_buffer **mem_buf, int is_mmap)
+{
+ struct v4l2_requestbuffers req;
+ struct v4l2_dst_buffer *out_buf;
+ int idx;
+
+ if(fd<0)
+ {
+ fprintf(stderr,"device not opened : %d\n",fd);
+ return -1;
+ }
+
+ CLEAR (req);
+
+ req.count = num_buf;
+ req.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ if (is_mmap == 0)
+ req.memory = V4L2_MEMORY_USERPTR;
+ else
+ req.memory = V4L2_MEMORY_MMAP;
+ if (ioctl (fd, VIDIOC_REQBUFS, &req) < 0)
+ {
+ if (EINVAL == errno)
+ {
+ fprintf(stderr,"Not Support memory mapping\n");
+ return -1;
+ }
+ else
+ {
+ fprintf(stderr,"Error in VIDIOC_REQBUFS (%s)\n",strerror(errno));
+ return -1;
+ }
+ }
+
+ if (is_mmap)
+ {
+ out_buf = calloc(req.count, sizeof(struct v4l2_dst_buffer));
+ if(out_buf == NULL)
+ {
+ fprintf(stderr,"calloc fail (num:%d, size:%d)\n",
+ req.count,
+ sizeof(struct v4l2_dst_buffer));
+ return -1;
+ }
+
+ for(idx = 0; idx < num_buf; idx++)
+ {
+ struct v4l2_buffer set_buf;
+
+ CLEAR(set_buf);
+ set_buf.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ set_buf.memory = V4L2_MEMORY_MMAP;
+ set_buf.index = idx;
+
+ if(-1 == ioctl(fd, VIDIOC_QUERYBUF, &set_buf))
+ {
+ fprintf(stderr,"Error in VIDIOC_QUERYBUF (%s)\n",
+ strerror(errno));
+ if (out_buf)
+ free(out_buf);
+ return -1;
+ }
+
+ out_buf[idx].index = idx;
+ out_buf[idx].size = set_buf.length;
+ out_buf[idx].buf = mmap (NULL /* start anywhere */,
+ set_buf.length,
+ PROT_READ | PROT_WRITE /* required */,
+ MAP_SHARED /* recommended */,
+ fd, set_buf.m.offset & ~(PAGE_SIZE - 1 ));
+
+ out_buf[idx].buf += set_buf.m.offset & (PAGE_SIZE - 1);
+ if(out_buf[idx].buf == MAP_FAILED)
+ {
+ fprintf(stderr,"mmap fail (%d)\n",idx);
+ free(out_buf);
+ return -1;
+ }
+ else
+ {
+ fprintf(stderr,"mmaped addr (%p)\n", out_buf[idx].buf);
+ }
+ }
+
+ *mem_buf = out_buf;
+ }
+ return 0;
+}
+
+int v4l2_clr_buf(int fd, int num_buf, struct v4l2_dst_buffer *mem_buf, enum v4l2_buf_type type, int is_mmap)
+{
+ unsigned int i;
+ struct v4l2_requestbuffers req;
+
+ if(fd < 0)
+ {
+ fprintf(stderr,"device not opened : %d\n",fd);
+ return -1;
+ }
+
+ if (is_mmap)
+ {
+ for (i = 0; i < num_buf; ++i)
+ {
+ if (mem_buf[i].buf)
+ {
+ if (-1 == munmap (mem_buf[i].buf,
+ mem_buf[i].size))
+ printf ("Failed to unmap v4l2 buffer \
+ at index %d\n", i);
+ }
+ }
+ free(mem_buf);
+ }
+
+ CLEAR (req);
+ req.count = 0;
+ req.type = type;
+ if (is_mmap == 0)
+ req.memory = V4L2_MEMORY_USERPTR;
+ else
+ req.memory = V4L2_MEMORY_MMAP;
+ if (ioctl (fd, VIDIOC_REQBUFS, &req) == -1)
+ {
+ if (EINVAL == errno)
+ fprintf(stderr,"%d does not support memory mapping\n", fd);
+ else
+ fprintf(stderr,"Error in VIDIOC_REQBUFS (%s)\n\n", strerror (errno));
+ }
+
+ return 0;
+}
+
+int v4l2_set_dst(int fd, struct v4l2_rect *dst, struct v4l2_rect *win, int rotation, int xres, int yres)
+{
+ struct v4l2_capability cap;
+ int ret_val;
+ struct v4l2_format fmt;
+
+ if(fd < 0)
+ {
+ fprintf(stderr, "device not opened : %d\n",fd);
+ return -1;
+ }
+
+ CLEAR(cap);
+ if (-1 == ioctl (fd, VIDIOC_QUERYCAP, &cap))
+ {
+ fprintf(stderr,"Failed to query capabilities of device %d (%s)\n", fd, strerror (errno));
+ return -1;
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_VIDEO_OVERLAY))
+ {
+ fprintf(stderr,"%d is no video overlay\n", fd);
+ return -1;
+ }
+
+ /* Video Overlay setting ============================================================== */
+ CLEAR(fmt);
+ fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ fmt.fmt.win.w.left = win->left;
+ fmt.fmt.win.w.top = win->top;
+ fmt.fmt.win.w.width = win->width;
+ fmt.fmt.win.w.height = win->height;
+
+ ret_val = ioctl(fd, VIDIOC_S_FMT, &fmt);
+ if (ret_val < 0)
+ {
+ fprintf(stderr, "Error in video VIDIOC_S_FMT (%s)\n",strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int v4l2_stream_on(int fd, enum v4l2_buf_type type)
+{
+ if (-1 == ioctl (fd, VIDIOC_STREAMON, &type))
+ {
+ fprintf(stderr, "Error in VIDIOC_STREAMON (%s)\n", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int v4l2_stream_off(int fd, enum v4l2_buf_type type)
+{
+ if (-1 == ioctl (fd, VIDIOC_STREAMOFF, &type))
+ {
+ fprintf(stderr, "Error in VIDIOC_STREAMOFF (%s)\n", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int v4l2_overlay_on(int fd)
+{
+ int power = 1;
+
+ if (-1 == ioctl (fd, VIDIOC_OVERLAY, &power))
+ {
+ fprintf(stderr, "Error in VIDIOC_OVERLAY : %d (%s)\n", power, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+
+int v4l2_overlay_off(int fd)
+{
+ int power = 0;
+
+ if (-1 == ioctl (fd, VIDIOC_OVERLAY, &power))
+ {
+ fprintf(stderr, "Error in VIDIOC_OVERLAY : %d (%s)\n", power, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+int v4l2_dequeue(int fd, enum v4l2_buf_type type, int is_mmap)
+{
+ struct v4l2_buffer buf;
+ int retry = 0;
+
+ CLEAR (buf);
+ buf.type = type;
+ if (is_mmap == 0)
+ buf.memory = V4L2_MEMORY_USERPTR;
+ else
+ buf.memory = V4L2_MEMORY_MMAP;
+again:
+ if (-1 == ioctl (fd, VIDIOC_DQBUF, &buf))
+ {
+ if (errno == EINTR)
+ {
+ if (retry < 100)
+ {
+ retry++;
+ goto again;
+ }
+ }
+ fprintf(stderr, "Error in VIDIOC_DQBUF : %s \n", strerror(errno));
+ return -1;
+ }
+
+ return buf.index;
+}
+
+int v4l2_queue(int fd, enum v4l2_buf_type type, int index, struct v4l2_src_buffer *src_buf, int is_mmap)
+{
+ struct v4l2_buffer buf;
+
+ CLEAR (buf);
+ buf.type = type;
+ if (is_mmap == 0)
+ {
+ buf.memory = V4L2_MEMORY_USERPTR;
+ buf.m.userptr = (unsigned long)src_buf;
+ buf.length = 0;
+ }
+ else
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = index;
+
+ if (-1 == ioctl (fd, VIDIOC_QBUF, &buf))
+ {
+ fprintf(stderr, "Error in VIDIOC_QBUF : %s \n", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <linux/videodev2.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define VIDEO_OUT_BUF_NUM 3
+
+#define CLEAR(x) memset (&(x), 0, sizeof (x))
+
+struct v4l2_src_buffer {
+ unsigned int base[3];
+ size_t length[3];
+};
+
+struct v4l2_dst_buffer{
+ int index;
+ int size;
+ unsigned char *buf;
+};
+
+/** --function define for display -------------------------**/
+int v4l2_close_fd(int fd);
+int v4l2_set_src(int fd, struct v4l2_rect *src, struct v4l2_rect *crop, unsigned int pixel_format);
+int v4l2_set_buf(int fd, int num_buf, struct v4l2_dst_buffer **mem_buf, int is_mmap);
+int v4l2_clr_buf(int fd, int num_buf, struct v4l2_dst_buffer *mem_buf, enum v4l2_buf_type type, int is_mmap);
+
+int v4l2_set_dst(int fd, struct v4l2_rect *dst, struct v4l2_rect *win, int rotation, int xres, int yres);
+int v4l2_stream_off(int fd, enum v4l2_buf_type type);
+int v4l2_stream_on(int fd, enum v4l2_buf_type type);
+int v4l2_queue(int fd, enum v4l2_buf_type type, int index, struct v4l2_src_buffer *src_buf, int is_mmap);
+int v4l2_dequeue(int fd, enum v4l2_buf_type type, int is_mmap);
+int v4l2_overlay_on(int fd);
+int v4l2_overlay_off(int fd);
+
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <linux/vt.h>
+#include <linux/fb.h>
+#include <linux/videodev2.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <poll.h>
+#include <signal.h>
+
+#include "fbdev_pixman.h"
+#include "v4l2config.h"
+#include "v4l2_output_api.h"
+
+typedef struct _VideoInfo
+{
+ char *video; /* video */
+ char *fb; /* output frame buffer */
+ int bOpened;
+} VideoInfo;
+
+typedef struct _FbPos
+{
+ int x;
+ int y;
+} FbPos;
+
+typedef struct _FbGeometry
+{
+ FbPos pos;
+ int width;
+ int height;
+} FbGeometry;
+
+typedef struct
+{
+ int index;
+
+ int video_fd;
+ int fb_fd;
+ char *fb_base;
+ FbGeometry fb_geometry;
+
+ struct
+ {
+ int init;
+ int w;
+ int h;
+ CRECT dest;
+ CRECT crop;
+ V4L2Videoformat format;
+ int rotate;
+ int hflip;
+ int vflip;
+ int requestbuffer;
+ int streamon;
+ int cur_idx;
+
+ void * last_buffer;
+ } status;
+
+ struct v4l2_src_buffer *src_buf;
+ struct v4l2_dst_buffer *dst_buf;
+ int ismmap;
+} DispHandle;
+
+static VideoInfo video_infos[] =
+{
+ { "/dev/video1", NULL, FALSE },
+ { "/dev/video2", NULL, FALSE },
+};
+
+#define INVALID_INDEX -1
+
+#ifndef SWAP
+#define SWAP(a, b) {int t; t = a; a = b; b = t;}
+#endif
+
+static int EnsureOverlayOff (int video_fd, int * streamon);
+
+int num_of_v4l2_devices = -1;
+
+static int
+OpenDisplay (void *pphandle, int index, int requestbuffer)
+{
+ DispHandle *hdisp = (DispHandle *)pphandle;
+
+ if (video_infos[index].bOpened)
+ {
+ ErrorF ("V4L2: Already opened : %s\n", video_infos[index].video);
+ return INVALID_INDEX;
+ }
+
+ if ((hdisp->video_fd = open (video_infos[index].video, O_RDWR)) <= 0)
+ {
+ ErrorF("V4L2: Cannot open device : %s\n", video_infos[index].video);
+ return INVALID_INDEX;
+ }
+
+ video_infos[index].bOpened = TRUE;
+
+ hdisp->status.rotate = -1;
+ hdisp->status.format = -1;
+ hdisp->status.cur_idx = -1;
+ hdisp->status.init = 0;
+ hdisp->ismmap = 1;
+
+ hdisp->index = index;
+
+ return index;
+}
+
+static int
+CloseDisplay (DispHandle *hdisp)
+{
+ if (hdisp->index < 0 || hdisp->index >= num_of_v4l2_devices)
+ return FALSE;
+
+ if (!EnsureOverlayOff (hdisp->video_fd, &hdisp->status.streamon)) // We will consider this as a LCD Off case.
+ {
+ return FALSE;
+ }
+
+ if (hdisp->status.requestbuffer > 0 &&
+ v4l2_clr_buf (hdisp->video_fd, hdisp->status.requestbuffer, hdisp->dst_buf, V4L2_BUF_TYPE_VIDEO_OVERLAY, hdisp->ismmap) < 0 )
+ {
+ ErrorF ("V4L2: v4l2_clr_buf error\n");
+ return FALSE;
+ }
+
+ if (v4l2_close_fd (hdisp->video_fd) < 0)
+ {
+ ErrorF("V4L2: Cannot close device\n");
+ return FALSE;
+ }
+
+ video_infos[hdisp->index].bOpened = FALSE;
+
+ return TRUE;
+}
+
+int
+GetDisplayNums (void)
+{
+#if ENABLE_V4L2
+ return (sizeof(video_infos) / sizeof(VideoInfo));
+#else
+ return 0;
+#endif
+}
+
+int
+AvailableDisplay (int index)
+{
+ return !video_infos[index].bOpened;
+}
+
+int
+CreateDisplay (void **pphandle, int index, int requestbuffer)
+{
+ if (num_of_v4l2_devices == -1)
+ num_of_v4l2_devices = sizeof(video_infos) / sizeof(VideoInfo);
+
+ if (pphandle == NULL)
+ return INVALID_INDEX;
+
+ if (index >= num_of_v4l2_devices)
+ {
+ ErrorF ("V4L2: Out of range : %d\n", index);
+ return INVALID_INDEX;
+ }
+
+ *pphandle = calloc(sizeof(DispHandle), 1);
+
+ if (*pphandle == NULL)
+ return INVALID_INDEX;
+
+ index = OpenDisplay(*pphandle, index, requestbuffer);
+ if (index == INVALID_INDEX)
+ {
+ free(*pphandle);
+ *pphandle = NULL;
+
+ return INVALID_INDEX;
+ }
+
+ return index;
+}
+
+int
+DeleteDisplay (void *phandle, int exit)
+{
+ DispHandle *hdisp = (DispHandle *)phandle;
+
+ if (hdisp == NULL)
+ return FALSE;
+
+ if (CloseDisplay(hdisp) == FALSE)
+ return FALSE;
+
+ free(hdisp);
+
+ return TRUE;
+}
+
+static int
+EnsureOverlayOff (int video_fd, int * streamon)
+{
+ if (*streamon == TRUE)
+ {
+ if (v4l2_overlay_off (video_fd) < 0)
+ {
+ ErrorF ("V4L2: v4l2_streamoff : %s\n", strerror(errno));
+ return FALSE;
+ }
+ *streamon = FALSE;
+ }
+ return TRUE;
+}
+
+static int
+CheckFormatChanged (void *phandle, int w, int h, CRECT *dest, CRECT *crop, V4L2Videoformat format, int rotate, int hflip, int vflip)
+{
+ DispHandle *hdisp = (DispHandle *)phandle;
+
+ if (hdisp == NULL)
+ return FALSE;
+
+ if (!hdisp->status.init)
+ return FALSE;
+
+ if (hdisp->status.w != w || hdisp->status.h != h || hdisp->status.format != format)
+ return TRUE;
+
+ if (hdisp->status.rotate != rotate)
+ return TRUE;
+
+ if (hdisp->status.hflip != hflip || hdisp->status.vflip != vflip)
+ return TRUE;
+
+ if (crop && memcmp(&hdisp->status.crop, crop, sizeof(CRECT)))
+ return TRUE;
+
+ if (dest && memcmp(&hdisp->status.dest, dest, sizeof(CRECT)))
+ return TRUE;
+
+ return FALSE;
+}
+
+static void
+ConvertToV4L2PixmapFormat (DispHandle *hdisp,
+ V4L2Videoformat format,
+ int *v4l2_format,
+ int *ismmap)
+{
+ if (!v4l2_format || !ismmap)
+ return;
+
+ *ismmap = 1;
+
+ switch(format)
+ {
+ case V4L2_VIDEO_FMT_RGB565:
+ *v4l2_format = V4L2_PIX_FMT_RGB565;
+ break;
+
+ case V4L2_VIDEO_FMT_RGB24:
+ *v4l2_format = V4L2_PIX_FMT_RGB24;
+ break;
+
+ case V4L2_VIDEO_FMT_RGB32:
+ *v4l2_format = V4L2_PIX_FMT_RGB32;
+ break;
+
+ case V4L2_VIDEO_FMT_UYVY:
+ *v4l2_format = V4L2_PIX_FMT_UYVY;
+ break;
+
+ case V4L2_VIDEO_FMT_YUY2:
+ case V4L2_VIDEO_FMT_YUYV:
+ *v4l2_format = V4L2_PIX_FMT_YUYV;
+ break;
+
+ case V4L2_VIDEO_FMT_SUY2:
+ *ismmap = 0;
+ *v4l2_format = V4L2_PIX_FMT_YUYV;
+ break;
+
+ case V4L2_VIDEO_FMT_YV12:
+ *v4l2_format = V4L2_PIX_FMT_YVU420;
+ break;
+
+ case V4L2_VIDEO_FMT_I420:
+ case V4L2_VIDEO_FMT_YU12:
+ *v4l2_format = V4L2_PIX_FMT_YUV420;
+ break;
+
+ case V4L2_VIDEO_FMT_S420:
+ *ismmap = 0;
+ *v4l2_format = V4L2_PIX_FMT_YUV420;
+ break;
+
+ case V4L2_VIDEO_FMT_NV12:
+ *ismmap = 0;
+ *v4l2_format = V4L2_PIX_FMT_NV12;
+ break;
+
+ default:
+ *v4l2_format = V4L2_PIX_FMT_UYVY;
+ ErrorF ("V4L2: Unsupported pixel format, So using UVYU format\n");
+ break;
+ }
+}
+
+int
+SetDisplayFormat (void *phandle,
+ int w, int h,
+ CRECT *dest, CRECT *crop, CRECT *win,
+ V4L2Videoformat format,
+ int rotate,
+ int hflip, int vflip,
+ int requestbuffer,
+ int *imagesize)
+{
+ DispHandle *hdisp = (DispHandle *)phandle;
+
+ if (CheckFormatChanged (hdisp, w, h, dest, crop, format, rotate, hflip, vflip))
+ {
+ CloseDisplay (hdisp);
+ OpenDisplay (hdisp, hdisp->index, requestbuffer);
+ }
+
+ if (hdisp->status.w != w || hdisp->status.h != h || hdisp->status.format != format)
+ {
+ struct v4l2_rect src_rect = { 0, 0, w, h };
+ struct v4l2_rect crop_rect = { crop->x, crop->y, crop->w, crop->h };
+ int v4l2_format;
+
+ EnsureOverlayOff (hdisp->video_fd, &hdisp->status.streamon);
+
+ ConvertToV4L2PixmapFormat (hdisp, format, &v4l2_format, &hdisp->ismmap);
+
+ if (hdisp->ismmap)
+ crop_rect = src_rect;
+ else
+ {
+ ErrorF ("V4L2: Emulfb doesn't support userptr. \n");
+ return FALSE;
+ }
+
+ if (v4l2_set_src (hdisp->video_fd, &src_rect, &crop_rect, v4l2_format) < 0)
+ {
+ ErrorF ("V4L2: v4l2_set_videoformat : %s | W(%d) H(%d) Format(%d)\n", strerror(errno), w, h, format);
+ return FALSE;
+ }
+ hdisp->status.w = w;
+ hdisp->status.h = h;
+ hdisp->status.format = format;
+ hdisp->status.crop = *crop;
+
+ hdisp->status.requestbuffer = 0;
+ hdisp->status.init = 1;
+ }
+
+ if (hdisp->status.rotate != rotate ||
+ (dest && memcmp(&hdisp->status.dest, dest, sizeof(CRECT))) ||
+ (hdisp->status.hflip != hflip || hdisp->status.vflip != vflip))
+ {
+ struct v4l2_rect dst = { dest->x, dest->y, dest->w, dest->h };
+ struct v4l2_rect winr = { win->x, win->y, win->w, win->h };
+
+ EnsureOverlayOff (hdisp->video_fd, &hdisp->status.streamon);
+
+ hdisp->status.cur_idx = 0;
+
+ if (v4l2_set_dst (hdisp->video_fd, &dst, &winr, rotate, 0, 0 ) < 0)
+ {
+ ErrorF ("V4L2: v4l2_set_dst : %s \n", strerror(errno));
+ return FALSE;
+ }
+
+ hdisp->status.rotate = rotate;
+ hdisp->status.hflip = hflip;
+ hdisp->status.vflip = vflip;
+ hdisp->status.dest = *dest;
+ }
+
+ if ( hdisp->status.requestbuffer != requestbuffer )
+ {
+ EnsureOverlayOff (hdisp->video_fd, &hdisp->status.streamon);
+ hdisp->status.cur_idx = 0;
+
+ if ( v4l2_set_buf(hdisp->video_fd, requestbuffer, &hdisp->dst_buf, hdisp->ismmap) < 0 )
+ {
+ ErrorF ("V4L2: v4l2_set_buf : %s \n", strerror(errno));
+ return FALSE;
+ }
+ hdisp->status.requestbuffer = requestbuffer;
+ }
+
+ if (hdisp->status.streamon == FALSE)
+ {
+ v4l2_overlay_on(hdisp->video_fd);
+ hdisp->status.streamon = TRUE;
+ }
+
+ return TRUE;
+}
+
+int
+DrawDisplay (void *phandle,
+ unsigned char *buf,
+ xRectangle *img,
+ xRectangle *pixmap,
+ xRectangle *draw,
+ xRectangle *src,
+ xRectangle *dst,
+ RegionPtr clip_region)
+{
+ DispHandle *hdisp = (DispHandle *)phandle;
+ pixman_format_code_t src_format, dst_format;
+ int i;
+
+ switch (hdisp->status.format)
+ {
+ case V4L2_VIDEO_FMT_I420:
+ case V4L2_VIDEO_FMT_YV12:
+ src_format = PIXMAN_yv12;
+ break;
+ case V4L2_VIDEO_FMT_YUY2:
+ src_format = PIXMAN_yuy2;
+ break;
+ case V4L2_VIDEO_FMT_RGB565:
+ src_format = PIXMAN_r5g6b5;
+ break;
+ case V4L2_VIDEO_FMT_RGB24:
+ src_format = PIXMAN_r8g8b8;
+ break;
+ case V4L2_VIDEO_FMT_RGB32:
+ src_format = PIXMAN_a8r8g8b8;
+ break;
+ default:
+ return FALSE;
+ }
+
+ switch (hdisp->status.format)
+ {
+ case V4L2_VIDEO_FMT_YV12:
+ case V4L2_VIDEO_FMT_YUY2:
+ dst_format = PIXMAN_x8r8g8b8;
+ break;
+ default:
+ dst_format = PIXMAN_x8b8g8r8;
+ dst_format = PIXMAN_x8b8g8r8;
+ break;
+ }
+
+ /* support only RGB */
+ for(i = 0; i < hdisp->status.requestbuffer; i++)
+ fbdev_pixman_convert_image (img->width, img->height,
+ buf, hdisp->dst_buf[0].buf,
+ src_format, dst_format,
+ img, pixmap, draw, src, dst,
+ clip_region, hdisp->status.rotate,
+ hdisp->status.hflip, hdisp->status.vflip);
+
+ return TRUE;
+}
+
+void * GetCapture(void * phandle, unsigned short * width, unsigned short * height, int * rotation, V4L2Videoformat * format, int bUseRpScaler)
+{
+ DispHandle *hdisp = (DispHandle *)phandle;
+
+ *width = hdisp->status.w;
+ *height = hdisp->status.h;
+ *rotation = hdisp->status.rotate;
+ *format = hdisp->status.format;
+
+ return hdisp->status.last_buffer;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 "v4l2config.h"
+#include "v4l2_output_api.h"
+
+int GetDisplayNums (void);
+int AvailableDisplay (int index);
+
+int CreateDisplay(void **pphandle, int index, int requestbuffer);
+
+int DeleteDisplay(void *phandle, int exit);
+
+int SetDisplayFormat(void *phandle, int w, int h, CRECT *dest, CRECT *crop, CRECT *win, V4L2Videoformat format, int rotate, int hflip, int vflip, int requestbuffer, int *imagesize);
+
+int DrawDisplay (void *phandle,
+ unsigned char *buf,
+ xRectangle *img,
+ xRectangle *pixmap,
+ xRectangle *draw,
+ xRectangle *src,
+ xRectangle *dst,
+ RegionPtr clip_region);
+
+void * GetCapture(void * phandle, unsigned short * width, unsigned short * height, int * rotation, V4L2Videoformat * format, int bUseRpScaler);
+
+void * imgcpy(int width, int height,
+ void * d, int d_off_x, int d_off_y, int d_size_w, int d_size_h,
+ void *s, int s_off_x, int s_off_y, int s_size_w, int s_size_h,
+ int * pitches, int * offsets, int channel);
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 __V4L2CONFIG_H__
+#define __V4L2CONFIG_H__
+
+#define _V4L2_DEBUG // Disable this to speed up
+#define _NEON_MEMCPY_
+//#define RP_SCALER
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE (!FALSE)
+#endif
+
+typedef struct _CRECT
+{
+ int x;
+ int y;
+ int w;
+ int h;
+} CRECT;
+
+typedef enum {
+ V4L2_VIDEO_FMT_UNKNOWN,
+ V4L2_VIDEO_FMT_UYVY,
+ V4L2_VIDEO_FMT_YUYV,
+ V4L2_VIDEO_FMT_YUY2,
+ V4L2_VIDEO_FMT_YV12,
+ V4L2_VIDEO_FMT_SUY2,
+ V4L2_VIDEO_FMT_I420,
+ V4L2_VIDEO_FMT_S420,
+ V4L2_VIDEO_FMT_YU12,
+ V4L2_VIDEO_FMT_NV12,
+ V4L2_VIDEO_FMT_NV12T,
+ V4L2_VIDEO_FMT_RGB565,
+ V4L2_VIDEO_FMT_RGB24,
+ V4L2_VIDEO_FMT_RGB32,
+} V4L2Videoformat;
+
+#endif // __V4L2CONFIG_H__
--- /dev/null
+/*
+ * Copyright 2004 Keith Packard
+ * Copyright 2005 Eric Anholt
+ * Copyright 2006 Nokia Corporation
+ * Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+ *
+ * Permission to use, copy, modify, distribute and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the authors and/or copyright holders
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. The authors and
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without any express
+ * or implied warranty.
+ *
+ * THE AUTHORS AND COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include <X11/Xatom.h>
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include "fourcc.h"
+
+#include "fbdevhw.h"
+#include "damage.h"
+
+#include "xf86xv.h"
+
+#include "fbdev.h"
+
+#include "v4l2api.h"
+
+#include "fbdev_video.h"
+#include "fbdev_hw.h"
+
+#include "xv_types.h"
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+#ifndef max
+#define max(x, y) (((x) >= (y)) ? (x) : (y))
+#endif
+
+#define ENSURE_AREA(offset, length, max) length = (offset + length > max ? max - offset : length)
+
+#define SWAP(x, y, t) t = x, x = y, y = t
+
+static XF86VideoEncodingRec DummyEncoding[] =
+{
+ /* Max width and height are filled in later. */
+ { 0, "XV_IMAGE", -1, -1, { 1, 1 } },
+ { 1, "XV_IMAGE", 2560, 2560, { 1, 1 } },
+};
+
+#define FOURCC_RGB565 0x50424742
+#define XVIMAGE_RGB565 \
+ { \
+ FOURCC_RGB565, \
+ XvRGB, \
+ LSBFirst, \
+ {'R','G','B','P', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 16, \
+ XvPacked, \
+ 1, \
+ 16, 0x0000F800, 0x000007E0, 0x0000001F, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ {'R','G','B',0, \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_RGB32 0x34424752
+#define XVIMAGE_RGB32 \
+ { \
+ FOURCC_RGB32, \
+ XvRGB, \
+ LSBFirst, \
+ {'R','G','B','4', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 32, \
+ XvPlanar, \
+ 1, \
+ 24, 0x00FF0000, 0x0000FF00, 0x000000FF, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ {'X','R','G','B', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+static XF86ImageRec Images[] =
+{
+ XVIMAGE_I420,
+ XVIMAGE_YV12,
+ XVIMAGE_YUY2,
+ XVIMAGE_RGB32,
+ XVIMAGE_RGB565,
+};
+
+#define NUM_IMAGES (sizeof(Images) / sizeof(Images[0]))
+
+static XF86VideoFormatRec Formats[] =
+{
+ { 16, TrueColor },
+ { 24, TrueColor },
+ { 32, TrueColor },
+};
+
+#define NUM_FORMATS (sizeof(Formats) / sizeof(Formats[0]))
+
+static XF86AttributeRec Attributes[] =
+{
+ { 0, -1, 270, "_USER_WM_PORT_ATTRIBUTE_ROTATION" },
+ { 0, 0, 1, "_USER_WM_PORT_ATTRIBUTE_HFLIP" },
+ { 0, 0, 1, "_USER_WM_PORT_ATTRIBUTE_VFLIP" },
+ { 0, -1, 1, "_USER_WM_PORT_ATTRIBUTE_PREEMPTION" },
+ { 0, 0, 1, "_USER_WM_PORT_ATTRIBUTE_DRAWING_MODE" },
+ { 0, 0, 1, "_USER_WM_PORT_ATTRIBUTE_STREAM_OFF" },
+};
+
+#define NUM_ATTRIBUTES (sizeof(Attributes) / sizeof(Attributes[0]))
+#define FBDEV_MAX_PORT 32
+
+static void
+fbdevGetRotation(ScreenPtr pScreen, FBDevPortPrivPtr pPortPriv, DrawablePtr pDraw, int * rotation, int * screen_rotation, int * xres, int * yres)
+{
+ ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum];
+ FBDevPtr pFBDev = FBDEVPTR(pScrnInfo);
+
+ *rotation = 0;
+ *screen_rotation = 0;
+
+#ifdef RANDR
+ switch(pFBDev->rotate)
+ {
+ case RR_Rotate_270:
+ *screen_rotation += 90;
+ case RR_Rotate_180:
+ *screen_rotation += 90;
+ case RR_Rotate_90:
+ *screen_rotation += 90;
+ case RR_Rotate_0:
+ break;
+ }
+#endif
+
+ if (pPortPriv->rotation >= 0)
+ *rotation = pPortPriv->rotation;
+ *screen_rotation = (*rotation - *screen_rotation + 360) % 360;
+}
+
+typedef enum { _PAA_MIN, PAA_ROTATION, PAA_HFLIP, PAA_VFLIP, PAA_PREEMPTION, PAA_DRAWINGMODE, PAA_STREAMOFF, _PAA_MAX } PORT_ATTR_ATOM;
+static struct
+{
+ PORT_ATTR_ATOM paa;
+ const char * name;
+ Atom atom;
+} atom_list[] =
+{
+ { PAA_ROTATION, "_USER_WM_PORT_ATTRIBUTE_ROTATION", None },
+ { PAA_HFLIP, "_USER_WM_PORT_ATTRIBUTE_HFLIP", None },
+ { PAA_VFLIP, "_USER_WM_PORT_ATTRIBUTE_VFLIP", None },
+ { PAA_PREEMPTION, "_USER_WM_PORT_ATTRIBUTE_PREEMPTION", None },
+ { PAA_DRAWINGMODE, "_USER_WM_PORT_ATTRIBUTE_DRAWING_MODE", None },
+ { PAA_STREAMOFF, "_USER_WM_PORT_ATTRIBUTE_STREAM_OFF", None },
+};
+
+static Atom
+getPortAtom(PORT_ATTR_ATOM paa)
+{
+ int i;
+ static int n_atom_cnt = sizeof(atom_list) / sizeof(atom_list[0]);
+
+ if (paa <= _PAA_MIN || paa >= _PAA_MAX)
+ {
+ ErrorF("Error: Invalid Port Attribute Name!\n");
+ return None;
+ }
+ for (i=0; i<n_atom_cnt; i++)
+ {
+ if (paa == atom_list[i].paa)
+ {
+ if (atom_list[i].atom == None)
+ atom_list[i].atom = MakeAtom (atom_list[i].name , strlen (atom_list[i].name), TRUE);
+
+ return atom_list[i].atom;
+ }
+ }
+
+ ErrorF("Error: Unknown Port Attribute Name!\n");
+ return None;
+}
+
+/**
+ * Xv attributes get/set support.
+ */
+static int
+fbdevGetPortAttribute(ScrnInfoPtr pScrnInfo, Atom attribute, INT32 *value,
+ pointer data)
+{
+ FBDevPortPrivPtr pPortPriv = (FBDevPortPrivPtr) data;
+
+ if (attribute == getPortAtom(PAA_ROTATION))
+ {
+ *value = pPortPriv->rotation;
+ return Success;
+ }
+ else if (attribute == getPortAtom (PAA_HFLIP))
+ {
+ *value = pPortPriv->hflip;
+ return Success;
+ }
+ else if (attribute == getPortAtom (PAA_VFLIP))
+ {
+ *value = pPortPriv->vflip;
+ return Success;
+ }
+ else if (attribute == getPortAtom(PAA_PREEMPTION))
+ {
+ *value = pPortPriv->preemption;
+ return Success;
+ }
+ else if (attribute == getPortAtom(PAA_DRAWINGMODE))
+ {
+ *value = (pPortPriv->mode == MODE_VIRTUAL);
+ return Success;
+ }
+ return BadMatch;
+}
+
+static int
+fbdevSetPortAttribute(ScrnInfoPtr pScrnInfo, Atom attribute, INT32 value,
+ pointer data)
+{
+ FBDevPtr pFBDev = (FBDevPtr) pScrnInfo->driverPrivate;
+ FBDevPortPrivPtr pPortPriv = (FBDevPortPrivPtr) data;
+
+ if (attribute == getPortAtom(PAA_ROTATION))
+ {
+ pPortPriv->rotation = value;
+ return Success;
+ }
+ else if (attribute == getPortAtom (PAA_HFLIP))
+ {
+ pPortPriv->hflip = value;
+ return Success;
+ }
+ else if (attribute == getPortAtom (PAA_VFLIP))
+ {
+ pPortPriv->vflip = value;
+ return Success;
+ }
+ else if (attribute == getPortAtom(PAA_PREEMPTION))
+ {
+ pPortPriv->preemption = value;
+ return Success;
+ }
+ else if (attribute == getPortAtom(PAA_STREAMOFF))
+ {
+ DeleteDisplay(pPortPriv->v4l2_handle, 0);
+ pPortPriv->v4l2_handle = NULL;
+ pFBDev->v4l2_owner[pPortPriv->v4l2_index] = NULL;
+ return Success;
+ }
+ return BadMatch;
+}
+
+/**
+ * Clip the image size to the visible screen.
+ */
+static void
+fbdevQueryBestSize(ScrnInfoPtr pScrnInfo, Bool motion, short vid_w,
+ short vid_h, short dst_w, short dst_h,
+ unsigned int *p_w, unsigned int *p_h, pointer data)
+{
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+
+ if (dst_w < pScreen->width)
+ *p_w = dst_w;
+ else
+ *p_w = pScreen->width;
+
+ if (dst_h < pScreen->height)
+ *p_h = dst_h;
+ else
+ *p_h = pScreen->height;
+}
+
+/**
+ * Stop an overlay. exit is whether or not the client's exiting.
+ */
+void
+fbdevVideoStop(ScrnInfoPtr pScrnInfo, pointer data, Bool exit)
+{
+ FBDevPtr pFBDev = (FBDevPtr) pScrnInfo->driverPrivate;
+
+ FBDevPortPrivPtr pPortPriv = (FBDevPortPrivPtr) data;
+
+ if (pPortPriv->mode == MODE_V4L2)
+ {
+ if (pPortPriv->v4l2_handle && !DeleteDisplay(pPortPriv->v4l2_handle, 0))
+ {
+ }
+
+ pPortPriv->v4l2_handle = NULL;
+ pFBDev->v4l2_owner[pPortPriv->v4l2_index] = NULL;
+
+ if (pFBDev->bFbAlphaEnabled)
+ {
+ FBDevScreenAlphaDeinit(fbdevHWGetFD(pScrnInfo));
+ pFBDev->bFbAlphaEnabled = FALSE;
+ }
+ }
+ pPortPriv->mode = MODE_INIT;
+ pPortPriv->preemption = 0;
+ pPortPriv->rotation = -1;
+
+ if (exit)
+ {
+ REGION_EMPTY(pScrnInfo, &pPortPriv->clip);
+ }
+}
+
+/**
+ * ReputImage hook. We always fail here if we're mid-migration or
+ * on Hailstorm; we want stopped video to actually be _stopped_, due
+ * to Hailstorm limitations.
+ */
+static int
+fbdevReputImage( ScrnInfoPtr pScrnInfo, short drw_x, short drw_y,
+ RegionPtr clipBoxes, pointer data, DrawablePtr pDraw )
+
+{
+ return Success;
+}
+
+/**
+ * Give image size and pitches.
+ */
+static int
+fbdevQueryImageAttributes(ScrnInfoPtr pScrnInfo, int id, unsigned short *w,
+ unsigned short *h, int *pitches, int *offsets)
+{
+// FbdevLog("FBDEV", LOGLEVEL_DEBUG, "%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);
+ int size = 0, tmp = 0;
+
+ *w = (*w + 1) & ~1;
+ if (offsets)
+ offsets[0] = 0;
+
+ switch (id)
+ {
+ case FOURCC_RGB565:
+ size += (*w << 1);
+ if (pitches)
+ pitches[0] = size;
+ size *= *h;
+ break;
+ case FOURCC_RGB32:
+ size += (*w << 2);
+ if (pitches)
+ pitches[0] = size;
+ size *= *h;
+ break;
+ case FOURCC_I420:
+ case FOURCC_YV12:
+ size = *w;
+ if (pitches)
+ pitches[0] = size;
+
+ size *= *h;
+ if (offsets)
+ offsets[1] = size;
+
+ tmp = (*w >> 1);
+ if (pitches)
+ pitches[1] = pitches[2] = tmp;
+
+ tmp *= (*h >> 1);
+ size += tmp;
+ if (offsets)
+ offsets[2] = size;
+
+ size += tmp;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ size = *w << 1;
+ if (pitches)
+ pitches[0] = size;
+
+ size *= *h;
+ break;
+ default:
+ return BadIDChoice;
+ }
+
+ return size;
+}
+
+#define DONT_FILL_ALPHA -1
+
+static void
+fbdevDisplayVideo (PixmapPtr pPixmap, RegionPtr pRgn, unsigned char *buf, int src_x, int src_y, int width, int height, int alpha)
+{
+ xRectangle *rects, *r;
+ int bpp; //byte per pixel;
+ BoxPtr pBox = REGION_RECTS (pRgn);
+ int nBox = REGION_NUM_RECTS (pRgn);
+ int i, j;
+
+ unsigned char *pDst, *pSrc;
+ int offset_x=0, offset_y=0;
+#ifdef COMPOSITE
+ offset_x = pPixmap->screen_x;
+ offset_y = pPixmap->screen_y;
+#endif
+
+ rects = malloc (nBox * sizeof (xRectangle));
+ if (!rects)
+ goto bail0;
+ r = rects;
+
+ bpp = pPixmap->drawable.bitsPerPixel/8;
+
+ if (bpp != 4)
+ alpha = DONT_FILL_ALPHA;
+
+ while (nBox--)
+ {
+ r->x = pBox->x1 + pPixmap->drawable.x;
+ r->y = pBox->y1 + pPixmap->drawable.y;
+ r->width = pBox->x2 - pBox->x1;
+ r->height = pBox->y2 - pBox->y1;
+
+ if (buf)
+ {
+ pDst = (unsigned char*)pPixmap->devPrivate.ptr + ((r->y-offset_y) * pPixmap->devKind) + ((r->x-offset_x)*bpp);
+ pSrc = buf + (r->y - pRgn->extents.y1 + src_y)*width*bpp + (r->x - pRgn->extents.x1 + src_x)*bpp;
+
+ for(i=0; i<r->height; i++, pDst+=pPixmap->devKind, pSrc+=width*bpp)
+ {
+ memcpy(pDst, pSrc, r->width*bpp);
+ }
+ }
+
+ if (alpha != DONT_FILL_ALPHA)
+ {
+ pDst = (unsigned char*)pPixmap->devPrivate.ptr + ((r->y-offset_y) * pPixmap->devKind) + ((r->x-offset_x)*bpp);
+ for(i=0; i<r->height; i++, pDst+=pPixmap->devKind)
+ for(j=0; j<r->width; j++)
+ pDst[j*bpp + 3] = alpha;
+ }
+
+ r++;
+ pBox++;
+ }
+
+ free (rects);
+bail0:
+ ;
+}
+
+static int
+fbdevTranslateV4L2toFourCC(V4L2Videoformat format)
+{
+ switch (format)
+ {
+ case V4L2_VIDEO_FMT_I420:
+ return FOURCC_I420;
+ case V4L2_VIDEO_FMT_YUY2:
+ return FOURCC_YUY2;
+ case V4L2_VIDEO_FMT_YV12:
+ return FOURCC_YV12;
+ case V4L2_VIDEO_FMT_RGB32:
+ return FOURCC_RGB32;
+ case V4L2_VIDEO_FMT_RGB565:
+ return FOURCC_RGB565;
+ default:
+ return 0;
+ }
+}
+
+static int
+intersectXRectangles ( xRectangle * dest, xRectangle * rect1, xRectangle * rect2)
+{
+ if (dest == NULL || rect1 == NULL || rect2 == NULL)
+ return -1;
+
+ dest->x = rect1->x > rect2->x ? rect1->x : rect2->x;
+ dest->y = rect1->y > rect2->y ? rect1->y : rect2->y;
+ dest->width = (rect1->x + rect1->width < rect2->x + rect2->width ? rect1->x + rect1->width : rect2->x + rect2->width) - dest->x;
+ dest->height = (rect1->y + rect1->height < rect2->y + rect2->height ? rect1->y + rect1->height : rect2->y + rect2->height) - dest->y;
+
+ if (dest->width <= 0 || dest->height <= 0)
+ return 0;
+
+ return 1;
+}
+
+static int
+fbdevPutStill ( ScrnInfoPtr pScrnInfo,
+ short vid_x, short vid_y, short drw_x, short drw_y,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data, DrawablePtr pDraw )
+{
+ int ret = Success;
+ int rotation = 0;
+ unsigned short width, height;
+ V4L2Videoformat format;
+ FBDevPortPrivPtr pPortPriv = (FBDevPortPrivPtr) data;
+
+ if (pPortPriv->mode == MODE_INIT)
+ return Success;
+ if (pPortPriv->mode == MODE_V4L2 && pPortPriv->v4l2_handle == NULL)
+ return BadImplementation;
+
+ if (pPortPriv->mode == MODE_VIRTUAL)
+ return Success;
+
+ void * captured_image = GetCapture(pPortPriv->v4l2_handle, &width, &height, &rotation, &format, FALSE);
+ PixmapPtr pPixmap;
+
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+ if (pDraw->type == DRAWABLE_WINDOW)
+ pPixmap =
+ (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+ else
+ pPixmap = (PixmapPtr) pDraw;
+ int bpp = pPixmap->drawable.bitsPerPixel/8;
+
+ ENSURE_AREA(vid_x, vid_w, pDraw->width);
+ ENSURE_AREA(vid_y, vid_h, pDraw->height);
+
+ xRectangle ResultRect;
+ xRectangle vid = { vid_x, vid_y, vid_w, vid_h };
+
+ if (intersectXRectangles(&ResultRect, &vid, &pPortPriv->dst) <= 0)
+ return Success;
+
+ int x1, y1;
+ unsigned short w1, h1;
+ x1 = (ResultRect.x - pPortPriv->dst.x) * width / pPortPriv->dst.width;
+ y1 = (ResultRect.y - pPortPriv->dst.y) * height / pPortPriv->dst.height;
+ w1 = ResultRect.width * width / pPortPriv->dst.width;
+ h1 = ResultRect.height * height / pPortPriv->dst.height;
+
+ int x2, y2;
+ unsigned short w2, h2;
+ x2 = ResultRect.x * drw_w / vid.width;
+ y2 = ResultRect.y * drw_h / vid.height;
+ w2 = ResultRect.width * drw_w / vid.width;
+ h2 = ResultRect.height * drw_h / vid.height;
+
+ void * pToBeFreed[8] = { NULL, };
+ int nToBeFreed = 0;
+
+ void * src_buf = NULL;
+ void * dst_buf = NULL;
+
+ int pitches[3], offsets[3];
+
+ int src_format, dst_format;
+ src_format = fbdevTranslateV4L2toFourCC(format);
+
+ dst_format = FOURCC_RGB32;
+
+ src_buf = captured_image;
+
+ if ( (x1 || y1) || (w1 != width) || (h1 != height) )
+ {
+ int size = fbdevQueryImageAttributes(NULL, src_format, &w1, &h1, NULL, NULL);
+ pToBeFreed[nToBeFreed++] = dst_buf = malloc(size);
+
+ fbdevQueryImageAttributes(NULL, src_format, &width, &height, pitches, offsets);
+ imgcpy(w1, h1, dst_buf, 0, 0, w1, h1,
+ src_buf, x1, y1, width, height,
+ pitches, offsets, src_format == FOURCC_I420 ? 3 : 1);
+
+ src_buf = dst_buf;
+ }
+
+ if ( (w1 != w2) || (h1 != h2) || (src_format != dst_format) )
+ {
+ pToBeFreed[nToBeFreed++] = dst_buf = malloc(w2 * h2 * bpp);
+ src_buf = dst_buf;
+ }
+
+ if ( (x2 || y2) || (w2 != drw_w) || (h2 != drw_h) )
+ {
+ pitches[0] = w2 * bpp;
+ pToBeFreed[nToBeFreed++] = dst_buf = calloc(drw_w * drw_h, bpp);
+ imgcpy(w2, h2, dst_buf, x2, y2, drw_w, drw_h,
+ src_buf, 0, 0, w2, h2,
+ pitches, NULL, 1);
+
+ src_buf = dst_buf;
+ }
+
+ fbdevDisplayVideo (pPixmap, clipBoxes, src_buf, 0, 0, drw_w, drw_h, 0xFF);
+
+ DamageDamageRegion(pDraw, clipBoxes);
+
+ return ret;
+}
+
+static void cropLine(int * src, int * length, const int crop, const int crop_length)
+{
+ if (*src < crop)
+ {
+ *length = *length - (crop - *src);
+ *src = crop;
+ }
+ if (*src + *length > crop + crop_length)
+ *length = crop + crop_length - *src;
+}
+
+static void cropBox(int * src_x, int * src_y, int * src_w, int * src_h, const int crop_x, const int crop_y, const int crop_w, const int crop_h)
+{
+ cropLine(src_x, src_w, crop_x, crop_w);
+ cropLine(src_y, src_h, crop_y, crop_h);
+}
+
+static void subtractBox(int * src_x, int * src_y, int * src_w, int * src_h, const int margin_x1, const int margin_x2, const int margin_y1, const int margin_y2)
+{
+ *src_x += margin_x1;
+ *src_w -= margin_x1 + margin_x2;
+ *src_y += margin_y1;
+ *src_h -= margin_y1 + margin_y2;
+}
+
+static void
+cropWindow(int xres, int yres, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, CRECT * crop, CRECT * win, int rotation)
+{
+ int temp;
+
+ int dstX = dst_x;
+ int dstY = dst_y;
+ int dstW = dst_w;
+ int dstH = dst_h;
+
+ int marginX1, marginX2, marginY1, marginY2;
+
+ cropBox(&dst_x, &dst_y, &dst_w, &dst_h, 0, 0, xres, yres);
+
+ win->x = dst_x, win->y = dst_y, win->w = dst_w, win->h = dst_h;
+
+ marginX1 = dst_x - dstX;
+ marginX2 = (dstX + dstW) - (dst_x + dst_w);
+ marginY1 = dst_y - dstY;
+ marginY2 = (dstY + dstH) - (dst_y + dst_h);
+
+ switch(rotation)
+ {
+ case 90:
+ temp = marginX1;
+ marginX1 = marginY1;
+ marginY1 = marginX2;
+ marginX2 = marginY2;
+ marginY2 = temp;
+ temp = dstW;
+ dstW = dstH;
+ dstH = temp;
+ break;
+ case 180:
+ temp = marginX1;
+ marginX1 = marginX2;
+ marginX2 = temp;
+ temp = marginY1;
+ marginY1 = marginY2;
+ marginY2 = temp;
+ break;
+ case 270:
+ temp = marginX2;
+ marginX2 = marginY1;
+ marginY1 = marginX1;
+ marginX1 = marginY2;
+ marginY2 = temp;
+ temp = dstW;
+ dstW = dstH;
+ dstH = temp;
+ break;
+ }
+
+ marginX1 = marginX1 * src_w / dstW;
+ marginX2 = marginX2 * src_w / dstW;
+ marginY1 = marginY1 * src_h / dstH;
+ marginY2 = marginY2 * src_h / dstH;
+
+ subtractBox(&src_x, &src_y, &src_w, &src_h, marginX1, marginX2, marginY1, marginY2);
+
+ crop->x = src_x;
+ crop->y = src_y;
+ crop->w = src_w;
+ crop->h = src_h;
+}
+
+typedef struct
+{
+ int fourcc;
+ V4L2Videoformat v4l2_format;
+ Bool useDirectHWBuf;
+} FORMAT_TYPE;
+
+static FORMAT_TYPE format_table[] =
+{
+ { FOURCC_RGB565, V4L2_VIDEO_FMT_RGB565, FALSE },
+ { FOURCC_RGB32, V4L2_VIDEO_FMT_RGB32, FALSE },
+ { FOURCC_I420, V4L2_VIDEO_FMT_I420, FALSE },
+ { FOURCC_YUY2, V4L2_VIDEO_FMT_YUY2, FALSE },
+ { FOURCC_YV12, V4L2_VIDEO_FMT_YV12, FALSE },
+};
+
+static FORMAT_TYPE *
+getFormatInfo(int fourcc)
+{
+ int i;
+ static int size = sizeof(format_table) / sizeof(FORMAT_TYPE);
+
+ for (i = 0; i < size; i++)
+ {
+ if (format_table[i].fourcc == fourcc)
+ return &format_table[i];
+ }
+
+ ErrorF ("Emulator doens't support the '%c%c%c%c' type of image. \n",
+ fourcc & 0xFF, (fourcc & 0xFF00) >> 8, (fourcc & 0xFF0000) >> 16, (fourcc & 0xFF000000) >> 24);
+
+ return NULL;
+}
+
+static int
+parseFormatBuffer(unsigned char * buf, unsigned int * phy_addrs)
+{
+ XV_PUTIMAGE_DATA_PTR data = (XV_PUTIMAGE_DATA_PTR) buf;
+
+ int valid = XV_PUTIMAGE_VALIDATE_DATA(data);
+ if (valid < 0)
+ return valid;
+
+ if (phy_addrs == NULL)
+ return -0x10;
+
+ phy_addrs[0] = data->YPhyAddr;
+ phy_addrs[1] = data->CbPhyAddr;
+ phy_addrs[2] = data->CrPhyAddr;
+
+ return 0;
+}
+
+static int
+fbdevPutImage( ScrnInfoPtr pScrnInfo,
+ short src_x, short src_y, short dst_x, short dst_y,
+ short src_w, short src_h, short dst_w, short dst_h,
+ int id, unsigned char* buf, short width, short height, Bool sync,
+ RegionPtr clip_boxes, pointer data, DrawablePtr pDraw )
+{
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+ FBDevPtr pFBDev = (FBDevPtr) pScrnInfo->driverPrivate;
+
+ FBDevPortPrivPtr pPortPriv = (FBDevPortPrivPtr) data;
+
+ FBDEV_PORT_MODE modeBefore = pPortPriv->mode;
+
+ pPortPriv->pDraw = pDraw;
+ int rotation, screen_rotation;
+ int v4l2_index = 0;
+
+ V4L2Videoformat format;
+ int nBuffer = 1;
+
+ int pitches[3], offsets[3];
+ unsigned short w = width, h = height;
+ PixmapPtr pPixmap;
+
+ CRECT crop = {src_x, src_y, src_w, src_h};
+ CRECT win = {dst_x, dst_y, dst_w, dst_h};
+
+ int xres = pScreen->width, yres = pScreen->height;
+
+ FORMAT_TYPE * format_info = getFormatInfo(id);
+
+ unsigned int phy_addrs[4];
+ if (format_info == NULL)
+ return BadRequest;
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) pDraw);
+ else
+ pPixmap = (PixmapPtr) pDraw;
+
+ if (!pPortPriv->v4l2_handle)
+ {
+ pPortPriv->mode = MODE_VIRTUAL;
+
+ if (pPortPriv->preemption == 0)
+ {
+ int full = TRUE;
+ for (v4l2_index = 0; v4l2_index < pFBDev->v4l2_num; v4l2_index++)
+ if (AvailableDisplay (v4l2_index))
+ {
+ full = FALSE;
+ break;
+ }
+
+ if (full)
+ pPortPriv->mode = MODE_VIRTUAL;
+ else
+ pPortPriv->mode = MODE_V4L2;
+ }
+ else if (pPortPriv->preemption == 1)
+ {
+ int can_create = FALSE;
+ for (v4l2_index = 0; v4l2_index < pFBDev->v4l2_num; v4l2_index++)
+ {
+ FBDevPortPrivPtr pOwnerPort = (FBDevPortPrivPtr)pFBDev->v4l2_owner[v4l2_index];
+ if (!pOwnerPort)
+ {
+ can_create = TRUE;
+ pPortPriv->mode = MODE_V4L2;
+ break;
+ }
+ else if (pOwnerPort->preemption == 0)
+ {
+ can_create = TRUE;
+ fbdevPutStill (pScrnInfo,
+ pOwnerPort->dst.x, pOwnerPort->dst.y, pOwnerPort->dst.x, pOwnerPort->dst.y,
+ pOwnerPort->dst.width, pOwnerPort->dst.height, pOwnerPort->dst.width, pOwnerPort->dst.height,
+ &pOwnerPort->clipBoxes, pOwnerPort, pOwnerPort->pDraw);
+
+ DeleteDisplay(pOwnerPort->v4l2_handle, 0);
+ pOwnerPort->v4l2_handle = NULL;
+ pFBDev->v4l2_owner[v4l2_index] = NULL;
+
+ pOwnerPort->mode = MODE_VIRTUAL;
+ pPortPriv->mode = MODE_V4L2;
+ break;
+ }
+ }
+
+ if (!can_create)
+ {
+ return BadRequest;
+ }
+ }
+ }
+
+ fbdevGetRotation(pScrnInfo->pScreen, pPortPriv, pDraw, &rotation, &screen_rotation, &xres, &yres);
+
+ if (pPortPriv->mode == MODE_V4L2)
+ {
+ if (format_info->useDirectHWBuf)
+ {
+ int ret;
+ if ((ret = parseFormatBuffer(buf, phy_addrs)) < 0)
+ {
+ if (ret == XV_HEADER_ERROR)
+ ErrorF("XV_HEADER_ERROR\n");
+ else if (ret == XV_VERSION_MISMATCH)
+ ErrorF("XV_VERSION_MISMATCH\n");
+ if (ret == -0x10)
+ ErrorF("phy_addrs_ERROR\n");
+
+ return BadRequest;
+ }
+
+ /* Skip frame */
+ if (phy_addrs[0] == 0)
+ return Success;
+ }
+
+ cropWindow(xres, yres, src_x, src_y, src_w, src_h, dst_x, dst_y, dst_w, dst_h, &crop, &win, rotation);
+
+ if (!format_info->useDirectHWBuf)
+ {
+ src_x = crop.x;
+ src_y = crop.y;
+ src_w = crop.w;
+ src_h = crop.h;
+ crop.x = crop.y = 0;
+
+ width = src_w;
+ height = src_h;
+ }
+
+ format = format_info->v4l2_format;
+
+ if (!pPortPriv->v4l2_handle)
+ {
+ pPortPriv->v4l2_index = CreateDisplay (&pPortPriv->v4l2_handle, v4l2_index, nBuffer);
+ pFBDev->v4l2_owner[pPortPriv->v4l2_index] = (void *)pPortPriv;
+ }
+
+ if (pPortPriv->v4l2_handle)
+ {
+ if(SetDisplayFormat(pPortPriv->v4l2_handle, width, height,
+ &win, &crop, &win,
+ format, screen_rotation,
+ pPortPriv->hflip, pPortPriv->vflip,
+ nBuffer, &pPortPriv->size))
+ {
+ fbdevQueryImageAttributes(NULL, id, &w, &h, pitches, offsets);
+
+ xRectangle img = {0, 0, w, h};
+ xRectangle pxm = {0, 0, win.w, win.h};
+ xRectangle draw = {0, 0, win.w, win.h};
+ xRectangle src = {src_x, src_y, src_w, src_h};
+ xRectangle dst = {0, 0, win.w, win.h};
+
+ DrawDisplay (pPortPriv->v4l2_handle, buf, &img, &pxm, &draw, &src, &dst, clip_boxes);
+
+ if (modeBefore == MODE_VIRTUAL)
+ pScrnInfo->pScreen->WindowExposures((WindowPtr) pDraw, clip_boxes, NULL);
+
+ /* update cliplist */
+ if (!REGION_EQUAL(pScrnInfo->pScreen, &pPortPriv->clip, clip_boxes))
+ {
+ /* setting transparency length to 8 */
+ if (!pFBDev->bFbAlphaEnabled)
+ {
+ FBDevScreenAlphaInit(fbdevHWGetFD(pScrnInfo));
+ pFBDev->bFbAlphaEnabled = TRUE;
+ }
+ }
+
+ return Success;
+ }
+ DeleteDisplay(pPortPriv->v4l2_handle, 0);
+ pPortPriv->v4l2_handle = NULL;
+ pFBDev->v4l2_owner[pPortPriv->v4l2_index] = NULL;
+ }
+
+ pPortPriv->mode = MODE_VIRTUAL;
+ }
+
+ if (pPortPriv->mode == MODE_VIRTUAL)
+ {
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+ PixmapPtr pPixmap;
+
+ if (src_w != dst_w || src_h != dst_h)
+ {
+ return BadRequest;
+ }
+ if (id != FOURCC_RGB32)
+ {
+ return BadRequest;
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ pPixmap =
+ (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+ else
+ pPixmap = (PixmapPtr) pDraw;
+
+ fbdevDisplayVideo (pPixmap, clip_boxes, buf, src_x, src_y, width, height, DONT_FILL_ALPHA);
+
+ DamageDamageRegion(pDraw, clip_boxes);
+
+ if (modeBefore == MODE_V4L2)
+ {
+ if (!DeleteDisplay(pPortPriv->v4l2_handle, 0))
+ {
+ }
+ pPortPriv->v4l2_handle = NULL;
+ pFBDev->v4l2_owner[pPortPriv->v4l2_index] = NULL;
+ }
+
+ return Success;
+ }
+
+ return Success;
+}
+
+/**
+ * Set up all our internal structures.
+ */
+static XF86VideoAdaptorPtr
+fbdevSetupImageVideo(ScreenPtr pScreen)
+{
+ XF86VideoAdaptorPtr pAdaptor;
+ FBDevPortPrivPtr pPortPriv;
+
+ int i;
+
+ pAdaptor = calloc(1, sizeof(XF86VideoAdaptorRec) +
+ (sizeof(DevUnion) + sizeof(FBDevPortPriv)) * FBDEV_MAX_PORT);
+ if (pAdaptor == NULL)
+ return NULL;
+
+ DummyEncoding[0].width = pScreen->width;
+ DummyEncoding[0].height = pScreen->height;
+
+ pAdaptor->type = XvWindowMask | XvInputMask | XvImageMask | XvStillMask;
+ pAdaptor->flags = (VIDEO_CLIP_TO_VIEWPORT | VIDEO_OVERLAID_IMAGES);
+ pAdaptor->name = "FBDEV supporting Software Video Conversions";
+ pAdaptor->nEncodings = sizeof(DummyEncoding) / sizeof(XF86VideoEncodingRec);
+ pAdaptor->pEncodings = DummyEncoding;
+ pAdaptor->nFormats = NUM_FORMATS;
+ pAdaptor->pFormats = Formats;
+ pAdaptor->nPorts = FBDEV_MAX_PORT;
+ pAdaptor->pPortPrivates = (DevUnion *)(&pAdaptor[1]);
+
+ pPortPriv =
+ (FBDevPortPrivPtr)(&pAdaptor->pPortPrivates[FBDEV_MAX_PORT]);
+
+ for(i=0; i<FBDEV_MAX_PORT; i++)
+ {
+ pAdaptor->pPortPrivates[i].ptr = &pPortPriv[i];
+
+ pPortPriv[i].index = i;
+ pPortPriv[i].rotation = -1;
+
+ REGION_INIT(pScreen, &pPortPriv[i].clipBoxes, NullBox, 0);
+ }
+
+ pAdaptor->nAttributes = NUM_ATTRIBUTES;
+ pAdaptor->pAttributes = Attributes;
+ pAdaptor->nImages = NUM_IMAGES;
+ pAdaptor->pImages = Images;
+
+ pAdaptor->PutStill = fbdevPutStill;
+ pAdaptor->PutImage = fbdevPutImage;
+ pAdaptor->ReputImage = fbdevReputImage;
+ pAdaptor->StopVideo = fbdevVideoStop;
+ pAdaptor->GetPortAttribute = fbdevGetPortAttribute;
+ pAdaptor->SetPortAttribute = fbdevSetPortAttribute;
+ pAdaptor->QueryBestSize = fbdevQueryBestSize;
+ pAdaptor->QueryImageAttributes = fbdevQueryImageAttributes;
+
+ return pAdaptor;
+}
+
+/**
+ * Set up everything we need for Xv.
+ */
+Bool fbdevVideoInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum];
+ FBDevPtr pFBDev = (FBDevPtr) pScrnInfo->driverPrivate;
+
+ pFBDev->pAdaptor = fbdevSetupImageVideo(pScreen);
+
+ if (pFBDev->pAdaptor)
+ {
+ xf86XVScreenInit(pScreen, &pFBDev->pAdaptor, 1);
+ pFBDev->v4l2_num = GetDisplayNums ();
+ pFBDev->v4l2_owner = (void**)calloc(sizeof (void*), pFBDev->v4l2_num);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+/**
+ * Shut down Xv, used on regeneration.
+ */
+void fbdevVideoFini(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum];
+ FBDevPtr pFBDev = (FBDevPtr) pScrnInfo->driverPrivate;
+
+ XF86VideoAdaptorPtr pAdaptor = pFBDev->pAdaptor;
+ int i;
+
+ if (!pAdaptor)
+ return;
+
+ for(i = 0; i < FBDEV_MAX_PORT; i++)
+ {
+ FBDevPortPrivPtr pPortPriv = (FBDevPortPrivPtr) pAdaptor->pPortPrivates[i].ptr;
+
+ REGION_UNINIT(pScreen, &pPortPriv->clipBoxes);
+
+ if(pPortPriv->v4l2_handle)
+ DeleteDisplay(pPortPriv->v4l2_handle, 0);
+ }
+
+ free(pAdaptor);
+ pFBDev->pAdaptor = NULL;
+
+ if (pFBDev->v4l2_owner)
+ {
+ free(pFBDev->v4l2_owner);
+ pFBDev->v4l2_owner = NULL;
+ pFBDev->v4l2_num = 0;
+ }
+}
+
+int
+fbdevVideoProcessArgument (int argc, char **argv, int i)
+{
+ return 1;
+}
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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 FBDEV_VIDEO_H
+#define FBDEV_VIDEO_H
+
+typedef enum {
+ MODE_INIT,
+ MODE_V4L2,
+ MODE_VIRTUAL
+} FBDEV_PORT_MODE;
+
+/* FBDev port information structure */
+typedef struct {
+ int index;
+ FBDEV_PORT_MODE mode;
+ int size;
+
+ RegionRec clip;
+
+ int rotation;
+ int hflip;
+ int vflip;
+ xRectangle dst;
+ RegionRec clipBoxes;
+ int preemption; /* 1:high, 0:default, -1:low */
+ DrawablePtr pDraw;
+
+ int v4l2_index;
+ void *v4l2_handle;
+} FBDevPortPriv, *FBDevPortPrivPtr;
+
+extern Bool fbdevVideoInit(ScreenPtr pScreen);
+
+extern void fbdevVideoFini(ScreenPtr pScreen);
+
+#endif // FBDEV_VIDEO_H
--- /dev/null
+/**************************************************************************
+
+xserver-xorg-video-emulfb
+
+Copyright 2010 - 2011 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: YoungHoon Jung <yhoon.jung@samsung.com>
+
+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, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
+
+**************************************************************************/
+
+/* */
+/* File name : xv_types.h */
+/* Author : YoungHoon Jung (yhoon.jung@samsung.com) */
+/* Protocol Version : 1.0.1 (Dec 16th 2009) */
+/* This file is for describing Xv APIs' buffer encoding method. */
+/* */
+
+#define XV_PUTIMAGE_HEADER 0xDEADCD01
+#define XV_PUTIMAGE_VERSION 0x00010001
+
+/* Return Values */
+#define XV_OK 0
+#define XV_HEADER_ERROR -1
+#define XV_VERSION_MISMATCH -2
+
+/* Data structure for XvPutImage / XvShmPutImage */
+typedef struct {
+ unsigned int _header; /* for internal use only */
+ unsigned int _version; /* for internal use only */
+
+ unsigned int YPhyAddr;
+ unsigned int CbPhyAddr;
+ unsigned int CrPhyAddr;
+ unsigned int RotAngle;
+ unsigned int VideoMode;
+} XV_PUTIMAGE_DATA, * XV_PUTIMAGE_DATA_PTR;
+
+static void
+#ifdef __GNUC__
+__attribute__ ((unused))
+#endif
+XV_PUTIMAGE_INIT_DATA(XV_PUTIMAGE_DATA_PTR data)
+{
+ data->_header = XV_PUTIMAGE_HEADER;
+ data->_version = XV_PUTIMAGE_VERSION;
+}
+
+
+static int
+#ifdef __GNUC__
+__attribute__ ((unused))
+#endif
+XV_PUTIMAGE_VALIDATE_DATA(XV_PUTIMAGE_DATA_PTR data)
+{
+ if (data->_header != XV_PUTIMAGE_HEADER)
+ return XV_HEADER_ERROR;
+ if (data->_version != XV_PUTIMAGE_VERSION)
+ return XV_VERSION_MISMATCH;
+ return XV_OK;
+}