summaryrefslogtreecommitdiff
path: root/staging
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-02-12 23:15:07 +0000
committerroot <root@rshg054.dnsready.net>2012-02-12 23:15:07 +0000
commit0020cc650ff973f269f23332e82fc097254d0adc (patch)
tree4eb4ed0d80064cbc09ee64ac2f9a4dc53ef2fb89 /staging
parentcfceb92e73d7f6a32494f0ba258b98748af43f34 (diff)
Sun Feb 12 23:15:07 UTC 2012
Diffstat (limited to 'staging')
-rw-r--r--staging/xf86-input-synaptics/10-synaptics.conf9
-rw-r--r--staging/xf86-input-synaptics/PKGBUILD48
-rw-r--r--staging/xf86-video-cirrus/PKGBUILD33
-rw-r--r--staging/xf86-video-cirrus/cirrus-1.3.2-git.patch846
-rw-r--r--staging/xf86-video-dummy/PKGBUILD30
-rw-r--r--staging/xf86-video-fbdev/PKGBUILD30
-rw-r--r--staging/xf86-video-glint/PKGBUILD30
-rw-r--r--staging/xf86-video-i128/PKGBUILD33
-rw-r--r--staging/xf86-video-i128/i128-1.3.4-git.patch173
-rw-r--r--staging/xf86-video-i740/PKGBUILD30
-rw-r--r--staging/xf86-video-intel/PKGBUILD30
-rw-r--r--staging/xf86-video-mach64/PKGBUILD30
-rw-r--r--staging/xf86-video-mga/PKGBUILD34
-rw-r--r--staging/xf86-video-mga/git-fixes.patch800
-rw-r--r--staging/xf86-video-neomagic/PKGBUILD30
-rw-r--r--staging/xf86-video-nv/PKGBUILD31
-rw-r--r--staging/xf86-video-r128/PKGBUILD36
-rw-r--r--staging/xf86-video-r128/git-fixes.patch842
-rw-r--r--staging/xf86-video-rendition/PKGBUILD35
-rw-r--r--staging/xf86-video-rendition/rendition-4.2.4-git.patch809
-rw-r--r--staging/xf86-video-s3/LICENSE25
-rw-r--r--staging/xf86-video-s3/PKGBUILD35
-rw-r--r--staging/xf86-video-s3/git-fixes.patch458
-rw-r--r--staging/xf86-video-s3virge/PKGBUILD38
-rw-r--r--staging/xf86-video-s3virge/copyright.patch82
-rw-r--r--staging/xf86-video-s3virge/s3virge-1.10.4-vga.patch76
-rw-r--r--staging/xf86-video-savage/PKGBUILD31
-rw-r--r--staging/xf86-video-siliconmotion/PKGBUILD35
-rw-r--r--staging/xf86-video-siliconmotion/smi-1.7.5-vga.patch25
-rw-r--r--staging/xf86-video-sis/PKGBUILD34
-rw-r--r--staging/xf86-video-sis/sis-0.10.3-git.patch1460
-rw-r--r--staging/xf86-video-sisusb/PKGBUILD33
-rw-r--r--staging/xf86-video-sisusb/sisusb-0.9.4-git.patch794
-rw-r--r--staging/xf86-video-tdfx/PKGBUILD36
-rw-r--r--staging/xf86-video-trident/PKGBUILD34
-rw-r--r--staging/xf86-video-trident/trident-1.3.4-git.patch523
-rw-r--r--staging/xf86-video-tseng/PKGBUILD33
-rw-r--r--staging/xf86-video-tseng/tseng-1.2.4-git.patch317
-rw-r--r--staging/xf86-video-unichrome/LICENSE23
-rw-r--r--staging/xf86-video-unichrome/PKGBUILD30
-rw-r--r--staging/xf86-video-v4l/LICENSE826
-rw-r--r--staging/xf86-video-v4l/PKGBUILD36
-rw-r--r--staging/xf86-video-v4l/git-fixes.patch4362
-rw-r--r--staging/xf86-video-vesa/PKGBUILD40
-rw-r--r--staging/xf86-video-vesa/git-fixes.patch444
-rw-r--r--staging/xf86-video-vesa/revert-kernelcheck.patch31
-rw-r--r--staging/xf86-video-voodoo/PKGBUILD30
-rw-r--r--staging/xf86-video-xgixp/PKGBUILD33
-rw-r--r--staging/xf86-video-xgixp/api-compat-fix-for-DRAWABLE_BUFFER.patch23
-rw-r--r--staging/xorg-server/PKGBUILD18
50 files changed, 13895 insertions, 9 deletions
diff --git a/staging/xf86-input-synaptics/10-synaptics.conf b/staging/xf86-input-synaptics/10-synaptics.conf
new file mode 100644
index 000000000..81a90fb81
--- /dev/null
+++ b/staging/xf86-input-synaptics/10-synaptics.conf
@@ -0,0 +1,9 @@
+Section "InputClass"
+ Identifier "touchpad catchall"
+ Driver "synaptics"
+ MatchIsTouchpad "on"
+ MatchDevicePath "/dev/input/event*"
+ Option "TapButton1" "1"
+ Option "TapButton2" "2"
+ Option "TapButton3" "3"
+EndSection
diff --git a/staging/xf86-input-synaptics/PKGBUILD b/staging/xf86-input-synaptics/PKGBUILD
new file mode 100644
index 000000000..7a9ea03ab
--- /dev/null
+++ b/staging/xf86-input-synaptics/PKGBUILD
@@ -0,0 +1,48 @@
+# $Id: PKGBUILD 149904 2012-02-11 13:11:31Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+# Contributor: Tobias Powalowski <tpowa@archlinux.org>
+# Contributor: Thomas Bächler <thomas@archlinux.org>
+# Contributor: Alexander Baldeck <alexander@archlinux.org>
+
+pkgname=xf86-input-synaptics
+pkgver=1.5.99
+pkgrel=0.1
+_gitver=e6032c34515a19ebac09090028f806d82ddfb62d
+pkgdesc="Synaptics driver for notebook touchpads"
+arch=('i686' 'x86_64')
+license=('custom')
+url="http://xorg.freedesktop.org/"
+depends=('libxtst')
+makedepends=('xorg-server-devel>=1.11.99.902' 'libxi' 'libx11')
+conflicts=('xorg-server<1.11.99.902')
+replaces=('synaptics')
+provides=('synaptics')
+conflicts=('synaptics')
+groups=('xorg-drivers' 'xorg')
+options=(!libtool)
+backup=('etc/X11/xorg.conf.d/10-synaptics.conf')
+source=(#http://xorg.freedesktop.org/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ http://cgit.freedesktop.org/xorg/driver/xf86-input-synaptics/snapshot/xf86-input-synaptics-${_gitver}.tar.gz
+ 10-synaptics.conf)
+md5sums=('82556d741fe2bc45c4ab4648cb77700d'
+ '3b81a81b958dfe3cac3cdef7ee85f1ce')
+
+build() {
+# cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${srcdir}/${pkgname}*
+ autoreconf -fi
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ #cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${srcdir}/${pkgname}*
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/etc/X11/xorg.conf.d"
+ install -m644 "${srcdir}/10-synaptics.conf" "${pkgdir}/etc/X11/xorg.conf.d/"
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+
+ rm -rf "${pkgdir}/usr/share/X11"
+}
diff --git a/staging/xf86-video-cirrus/PKGBUILD b/staging/xf86-video-cirrus/PKGBUILD
new file mode 100644
index 000000000..41513805f
--- /dev/null
+++ b/staging/xf86-video-cirrus/PKGBUILD
@@ -0,0 +1,33 @@
+# $Id: PKGBUILD 149842 2012-02-11 10:22:03Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-cirrus
+pkgver=1.3.2
+pkgrel=8
+pkgdesc="X.org Cirrus Logic video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ cirrus-1.3.2-git.patch)
+md5sums=('8195d03ed0be0975c03441e66a9f53b3'
+ '3e3677f330f1c24ce0f570c81f2b9de2')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/cirrus-1.3.2-git.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-cirrus/cirrus-1.3.2-git.patch b/staging/xf86-video-cirrus/cirrus-1.3.2-git.patch
new file mode 100644
index 000000000..5701a8473
--- /dev/null
+++ b/staging/xf86-video-cirrus/cirrus-1.3.2-git.patch
@@ -0,0 +1,846 @@
+diff --git a/Makefile.am b/Makefile.am
+index aa89732..7bd8873 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,17 +18,18 @@
+ # 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
++MAINTAINERCLEANFILES = ChangeLog INSTALL
+
+-EXTRA_DIST = README.multihead ChangeLog
++EXTRA_DIST = README.multihead
+
+-MAINTAINERCLEANFILES=ChangeLog
++.PHONY: ChangeLog INSTALL
+
+-.PHONY: ChangeLog
++INSTALL:
++ $(INSTALL_CMD)
+
+ ChangeLog:
+ $(CHANGELOG_CMD)
+
+-dist-hook: ChangeLog
++dist-hook: ChangeLog INSTALL
+
+diff --git a/configure.ac b/configure.ac
+index d205eb3..68c3eb3 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,47 +20,47 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-cirrus],
+- 1.3.2,
++ [1.3.2],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-cirrus)
+-
++ [xf86-video-cirrus])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
+-AM_INIT_AUTOMAKE([dist-bzip2])
+-
++# Initialize Automake
++AM_INIT_AUTOMAKE([foreign dist-bzip2])
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
+-m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.2)
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
++m4_ifndef([XORG_MACROS_VERSION],
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
++XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+-XORG_CWARNFLAGS
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.4 xproto fontsproto $REQUIRED_MODULES])
+-sdkdir=$(pkg-config --variable=sdkdir xorg-server)
+
+ # Checks for libraries.
+ SAVE_CPPFLAGS="$CPPFLAGS"
+@@ -78,21 +78,15 @@ if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+-# Checks for header files.
+-AC_HEADER_STDC
+
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=cirrus
+ AC_SUBST([DRIVER_NAME])
+
+-XORG_MANPAGE_SECTIONS
+-XORG_RELEASE_VERSION
+-XORG_CHANGELOG
+-
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index f0eb29b..1ea26b3 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,28 +1,25 @@
+ #
+-# 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.
+-#
++# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a
++# copy of this software and associated documentation files (the "Software"),
++# to deal in the Software without restriction, including without limitation
++# the rights to use, copy, modify, merge, publish, distribute, sublicense,
++# and/or sell copies of the Software, and to permit persons to whom the
++# Software is furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++# DEALINGS IN THE SOFTWARE.
++#
+
+ drivermandir = $(DRIVER_MAN_DIR)
+
+@@ -34,25 +31,11 @@ EXTRA_DIST = @DRIVER_NAME@.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+
+-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) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/cirrus.man b/man/cirrus.man
+index 009011e..af46248 100644
+--- a/man/cirrus.man
++++ b/man/cirrus.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.man,v 1.2 2001/01/27 18:20:47 dawes Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH CIRRUS __drivermansuffix__ __vendorversion__
+diff --git a/src/CirrusClk.c b/src/CirrusClk.c
+index a3590c9..6fd6270 100644
+--- a/src/CirrusClk.c
++++ b/src/CirrusClk.c
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/CirrusClk.c,v 1.8 1998/12/06 06:08:28 dawes Exp $ */
+-
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+diff --git a/src/alp.h b/src/alp.h
+index 01c5301..a182d0c 100644
+--- a/src/alp.h
++++ b/src/alp.h
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp.h,v 1.8 2001/10/01 13:44:05 eich Exp $ */
+-
+ /* (c) Itai Nahshon */
+
+ #ifndef ALP_H
+diff --git a/src/alp_driver.c b/src/alp_driver.c
+index fe81757..d3d8e4f 100644
+--- a/src/alp_driver.c
++++ b/src/alp_driver.c
+@@ -15,8 +15,6 @@
+ #include "config.h"
+ #endif
+
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c,v 1.35 2003/11/03 05:11:09 tsi Exp $ */
+-
+ /* All drivers should typically include these */
+ #include "xf86.h"
+ #include "xf86_OSproc.h"
+@@ -29,6 +27,10 @@
+ /* Drivers for PCI hardware need this */
+ #include "xf86PciInfo.h"
+
++#ifndef PCI_CHIP_GD7556 /* for old xf86PciInfo.h */
++#define PCI_CHIP_GD7556 0x004C
++#endif
++
+ /* Drivers that need to access the PCI config space directly need this */
+ #include "xf86Pci.h"
+
+@@ -119,6 +121,11 @@ static void AlpOffscreenAccelInit(ScrnInfoPtr pScrn);
+ static void AlpDisplayPowerManagementSet(ScrnInfoPtr pScrn,
+ int PowerManagementMode, int flags);
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++static void PC98CIRRUS755xEnable(ScrnInfoPtr pScrn);
++static void PC98CIRRUS755xDisable(ScrnInfoPtr pScrn);
++#endif
++
+ /*
+ * This is intentionally screen-independent. It indicates the binding
+ * choice made in the first PreInit.
+@@ -153,6 +160,8 @@ static int gd5430_MaxClocks[] = { 85500, 85500, 50000, 28500, 0 };
+ static int gd5446_MaxClocks[] = { 135100, 135100, 85500, 85500, 0 };
+ static int gd5480_MaxClocks[] = { 135100, 200000, 200000, 135100, 135100 };
+ static int gd7548_MaxClocks[] = { 80100, 80100, 80100, 80100, 80100 };
++static int gd7555_MaxClocks[] = { 80100, 80100, 80100, 80100, 80100 };
++static int gd7556_MaxClocks[] = { 80100, 80100, 80100, 80100, 80100 };
+
+ #ifdef XFree86LOADER
+
+@@ -248,7 +257,7 @@ AlpFreeRec(ScrnInfoPtr pScrn)
+ {
+ if (pScrn->driverPrivate == NULL)
+ return;
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -385,6 +394,11 @@ AlpCountRam(ScrnInfoPtr pScrn)
+ break;
+ }
+ break;
++
++ case PCI_CHIP_GD7555:
++ case PCI_CHIP_GD7556:
++ videoram = 2048; /* for PC-9821 La13 etc. */
++ break;
+ }
+
+ /* UNMap the Alp memory and MMIO areas */
+@@ -407,6 +421,8 @@ GetAccelPitchValues(ScrnInfoPtr pScrn)
+ {
+ int *linePitches = NULL;
+ int i, n = 0;
++ int max_pitch;
++
+ CirPtr pCir = CIRPTR(pScrn);
+
+ /* XXX ajv - 512, 576, and 1536 may not be supported
+@@ -423,8 +439,21 @@ GetAccelPitchValues(ScrnInfoPtr pScrn)
+ 1280, 1536, 1600, 1920, 2048, 0 };
+ #endif
+
++ switch (pCir->Chipset) {
++ case PCI_CHIP_GD5436:
++ case PCI_CHIP_GD5446:
++ max_pitch = 0x1ff << 3;
++ break;
++
++ default:
++ /* FIXME max_pitch for other chipsets? */
++ max_pitch = (pScrn->bitsPerPixel / 8) * 2048;
++ break;
++ }
++
+ for (i = 0; accelWidths[i] != 0; i++) {
+- if (accelWidths[i] % pCir->Rounding == 0) {
++ if ((accelWidths[i] % pCir->Rounding == 0)
++ && ((accelWidths[i] * pScrn->bitsPerPixel / 8) <= max_pitch)) {
+ n++;
+ linePitches = xnfrealloc(linePitches, n * sizeof(int));
+ linePitches[n - 1] = accelWidths[i];
+@@ -482,12 +511,17 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+
+ pCir = CIRPTR(pScrn);
+ pCir->pScrn = pScrn;
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ pCir->PIOReg = hwp->PIOOffset + 0x3CE;
++#else
++ pCir->PIOReg = 0x3CE;
++#endif
+
+ /* Get the entity, and make sure it is PCI. */
+ pCir->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+ if (pCir->pEnt->location.type != BUS_PCI) {
+- xfree(pCir->pEnt);
++ free(pCir->pEnt);
+ return FALSE;
+ }
+
+@@ -498,7 +532,8 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+ PCI_DEV_DEV(pCir->PciInfo),
+ PCI_DEV_FUNC(pCir->PciInfo));
+
+- if (xf86LoadSubModule(pScrn, "int10")) {
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (!xf86IsPc98() && xf86LoadSubModule(pScrn, "int10")) {
+ xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n");
+ pInt = xf86InitInt10(pCir->pEnt->index);
+ xf86FreeInt10(pInt);
+@@ -509,8 +544,8 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+
+ PCI_WRITE_LONG(pCir->PciInfo, PCI_REGION_BASE(pCir->PciInfo, 0, REGION_MEM), 0x10);
+ PCI_WRITE_LONG(pCir->PciInfo, PCI_REGION_BASE(pCir->PciInfo, 1, REGION_MEM), 0x14);
+-
+ }
++#endif
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+@@ -574,7 +609,7 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if (!(pCir->Options = xalloc(sizeof(CirOptions))))
++ if (!(pCir->Options = malloc(sizeof(CirOptions))))
+ return FALSE;
+ memcpy(pCir->Options, CirOptions, sizeof(CirOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pCir->Options);
+@@ -589,6 +624,16 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+
+ from = X_DEFAULT;
+ pCir->HWCursor = FALSE;
++
++ switch (pCir->Chipset) {
++ case PCI_CHIP_GD7555:
++ case PCI_CHIP_GD7556:
++ pCir->HWCursor = TRUE;
++ break;
++ default:
++ break;
++ }
++
+ if (xf86GetOptValBool(pCir->Options, OPTION_HW_CURSOR, &pCir->HWCursor))
+ from = X_CONFIG;
+
+@@ -863,10 +908,10 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+ case PCI_CHIP_GD5430:
+ case PCI_CHIP_GD5434_4:
+ case PCI_CHIP_GD5434_8:
+- case PCI_CHIP_GD5436:
+ /* case PCI_CHIP_GD5440: */
+ p = gd5430_MaxClocks;
+ break;
++ case PCI_CHIP_GD5436:
+ case PCI_CHIP_GD5446:
+ p = gd5446_MaxClocks;
+ break;
+@@ -876,6 +921,12 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
+ case PCI_CHIP_GD7548:
+ p = gd7548_MaxClocks;
+ break;
++ case PCI_CHIP_GD7555:
++ p = gd7555_MaxClocks;
++ break;
++ case PCI_CHIP_GD7556:
++ p = gd7556_MaxClocks;
++ break;
+ }
+ if (!p)
+ return FALSE;
+@@ -1360,6 +1411,11 @@ AlpModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+
+ vgaHWProtect(pScrn, FALSE);
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (xf86IsPc98())
++ PC98CIRRUS755xEnable(pScrn);
++#endif
++
+ return TRUE;
+ }
+
+@@ -1489,7 +1545,7 @@ AlpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+
+ if(pCir->shadowFB) {
+ pCir->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
+- pCir->ShadowPtr = xalloc(pCir->ShadowPitch * height);
++ pCir->ShadowPtr = malloc(pCir->ShadowPitch * height);
+ displayWidth = pCir->ShadowPitch / (pScrn->bitsPerPixel >> 3);
+ FbBase = pCir->ShadowPtr;
+ } else {
+@@ -1782,6 +1838,11 @@ AlpLeaveVT(int scrnIndex, int flags)
+
+ AlpRestore(pScrn);
+ vgaHWLock(hwp);
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (xf86IsPc98())
++ PC98CIRRUS755xDisable(pScrn);
++#endif
+ }
+
+
+@@ -1813,12 +1874,17 @@ AlpCloseScreen(int scrnIndex, ScreenPtr pScreen)
+ xf86DestroyCursorInfoRec(pCir->CursorInfoRec);
+ pCir->CursorInfoRec = NULL;
+ if (pCir->DGAModes)
+- xfree(pCir->DGAModes);
++ free(pCir->DGAModes);
+ pCir->DGAnumModes = 0;
+ pCir->DGAModes = NULL;
+
+ pScrn->vtSema = FALSE;
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (xf86IsPc98())
++ PC98CIRRUS755xDisable(pScrn);
++#endif
++
+ pScreen->CloseScreen = pCir->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ }
+@@ -2081,3 +2147,53 @@ AlpOffscreenAccelInit(ScrnInfoPtr pScrn)
+ box.y2 - pScrn->virtualY);
+ }
+ }
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++static void
++PC98CIRRUS755xEnable(ScrnInfoPtr pScrn) /* enter_aile() */
++{
++ unsigned int index,data;
++ vgaHWPtr hwp = VGAHWPTR(pScrn);
++
++ outb(0xfac, 0x02);
++
++ outb(0x68, 0x0e);
++ outb(0x6a, 0x07);
++ outb(0x6a, 0x8f);
++ outb(0x6a, 0x06);
++
++ outw(VGA_SEQ_INDEX, 0x1206); /* unlock cirrus special */
++
++ index = hwp->IOBase + VGA_CRTC_INDEX_OFFSET;
++ data = hwp->IOBase + VGA_CRTC_DATA_OFFSET;
++ outb(index, 0x3c);
++ outb(data, inb(data) & 0xef);
++ outb(index, 0x1a);
++ outb(data, inb(data) & 0xf3);
++}
++
++static void
++PC98CIRRUS755xDisable(ScrnInfoPtr pScrn) /* leave_aile() */
++{
++ unsigned int index,data;
++ vgaHWPtr hwp = VGAHWPTR(pScrn);
++
++ outw(VGA_SEQ_INDEX, 0x1206); /* unlock cirrus special */
++
++ index = hwp->IOBase + VGA_CRTC_INDEX_OFFSET;
++ data = hwp->IOBase + VGA_CRTC_DATA_OFFSET;
++ outb(index, 0x3c);
++ outb(data, 0x71);
++ outb(index, 0x1a);
++ outb(data, inb(data) | 0x0c);
++
++ outb(0xfac,0x00);
++
++ outb(0x68, 0x0f);
++ outb(0x6a, 0x07);
++ outb(0x6a, 0x8e);
++ outb(0x6a, 0x21);
++ outb(0x6a, 0x69);
++ outb(0x6a, 0x06);
++}
++#endif
+diff --git a/src/alp_hwcurs.c b/src/alp_hwcurs.c
+index 79dfce7..9891eb4 100644
+--- a/src/alp_hwcurs.c
++++ b/src/alp_hwcurs.c
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_hwcurs.c,v 1.4 2000/12/06 15:35:15 eich Exp $ */
+-
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+diff --git a/src/alp_i2c.c b/src/alp_i2c.c
+index 9e6ae67..7365215 100644
+--- a/src/alp_i2c.c
++++ b/src/alp_i2c.c
+@@ -4,8 +4,6 @@
+ #include "config.h"
+ #endif
+
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_i2c.c,v 1.6 1999/02/28 11:19:38 dawes Exp $ */
+-
+ #include "xf86.h"
+ #include "xf86_OSproc.h"
+ #include "compiler.h"
+diff --git a/src/alp_xaa.c b/src/alp_xaa.c
+index 95741fc..7a96e1a 100644
+--- a/src/alp_xaa.c
++++ b/src/alp_xaa.c
+@@ -4,8 +4,6 @@
+ #include "config.h"
+ #endif
+
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaa.c,v 1.7 2001/10/01 13:44:05 eich Exp $ */
+-
+ #include "xf86.h"
+ #include "xf86_OSproc.h"
+ #include "compiler.h"
+diff --git a/src/alp_xaam.c b/src/alp_xaam.c
+index 0193a43..3ecc7de 100644
+--- a/src/alp_xaam.c
++++ b/src/alp_xaam.c
+@@ -1,6 +1,5 @@
+ /* (c) Itai Nahshon */
+ /* #define DEBUG */
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_xaam.c,v 1.7 2001/10/01 13:44:05 eich Exp $ */
+
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+diff --git a/src/cir.h b/src/cir.h
+index 904d9cc..861966d 100644
+--- a/src/cir.h
++++ b/src/cir.h
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir.h,v 1.20 2002/01/04 21:26:54 tsi Exp $ */
+-
+ /* (c) Itai Nahshon */
+
+ #ifndef CIR_H
+@@ -23,7 +21,7 @@ typedef struct {
+ CARD32 properties;
+ pciVideoPtr PciInfo;
+ PCITAG PciTag;
+- IOADDRESS PIOReg;
++ unsigned long PIOReg;
+ union {
+ struct lgRec *lg;
+ struct alpRec *alp;
+diff --git a/src/cir_dga.c b/src/cir_dga.c
+index bc98df6..f930231 100644
+--- a/src/cir_dga.c
++++ b/src/cir_dga.c
+@@ -1,4 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_dga.c,v 1.5 2001/02/15 17:39:27 eich Exp $ */
+ /*
+ * Copyright 2000 by Egbert Eich
+ *
+@@ -83,9 +82,9 @@ CirDGAInit(ScreenPtr pScreen)
+ if (!pCir->DGAnumModes) {
+ pMode = firstMode = pScrn->modes;
+ while (pMode) {
+- newmodes = xrealloc(modes, (num + 1) * sizeof (DGAModeRec));
++ newmodes = realloc(modes, (num + 1) * sizeof (DGAModeRec));
+ if (!newmodes) {
+- xfree(modes);
++ free(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+diff --git a/src/cir_driver.c b/src/cir_driver.c
+index 5466c48..7e470bb 100644
+--- a/src/cir_driver.c
++++ b/src/cir_driver.c
+@@ -15,8 +15,6 @@
+ #include "config.h"
+ #endif
+
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c,v 1.67 2001/05/15 10:19:37 eich Exp $ */
+-
+ /* All drivers should typically include these */
+ #include "xf86.h"
+ #include "xf86_OSproc.h"
+@@ -29,6 +27,10 @@
+ /* Drivers for PCI hardware need this */
+ #include "xf86PciInfo.h"
+
++#ifndef PCI_CHIP_GD7556 /* for old xf86PciInfo.h */
++#define PCI_CHIP_GD7556 0x004C
++#endif
++
+ /* Drivers that need to access the PCI config space directly need this */
+ #include "xf86Pci.h"
+
+@@ -90,6 +92,8 @@ SymTabRec CIRChipsets[] = {
+ { PCI_CHIP_GD5464BD, "CL-GD5464BD" },
+ { PCI_CHIP_GD5465, "CL-GD5465" },
+ { PCI_CHIP_GD7548, "CL-GD7548" },
++ { PCI_CHIP_GD7555, "CL-GD7555" },
++ { PCI_CHIP_GD7556, "CL-GD7556" },
+ {-1, NULL }
+ };
+
+@@ -107,6 +111,8 @@ _X_EXPORT PciChipsets CIRPciChipsets[] = {
+ { PCI_CHIP_GD5464BD,PCI_CHIP_GD5464BD, RES_SHARED_VGA },
+ { PCI_CHIP_GD5465, PCI_CHIP_GD5465, RES_SHARED_VGA },
+ { PCI_CHIP_GD7548, PCI_CHIP_GD7548, RES_SHARED_VGA },
++ { PCI_CHIP_GD7555, PCI_CHIP_GD7555, RES_SHARED_VGA },
++ { PCI_CHIP_GD7556, PCI_CHIP_GD7556, RES_SHARED_VGA },
+ { -1, -1, RES_UNDEFINED}
+ };
+
+@@ -238,7 +244,7 @@ CIRProbe(DriverPtr drv, int flags)
+ CIRChipsets, CIRPciChipsets, devSections,
+ numDevSections, drv, &usedChips);
+ /* Free it since we don't need that list after this */
+- xfree(devSections);
++ free(devSections);
+ if (numUsed <= 0)
+ return FALSE;
+ if (flags & PROBE_DETECT)
+@@ -280,7 +286,7 @@ CIRProbe(DriverPtr drv, int flags)
+ pScrn->Probe = NULL;
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+
+ return foundScreen;
+ }
+diff --git a/src/cir_pcirename.h b/src/cir_pcirename.h
+index f0f5cf8..669b8fe 100644
+--- a/src/cir_pcirename.h
++++ b/src/cir_pcirename.h
+@@ -34,6 +34,33 @@ enum region_type {
+ REGION_IO
+ };
+
++#include "xf86Module.h"
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 12
++
++#if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
++#define PCI_DOM_MASK 0x01fful
++#else
++#define PCI_DOM_MASK 0x0ffu
++#endif
++
++#ifndef PCI_DOM_MASK
++# define PCI_DOM_MASK 0x0ffu
++#endif
++#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
++
++static inline uint32_t
++pciTag(int busnum, int devnum, int funcnum)
++{
++ uint32_t tag;
++ tag = (busnum & (PCI_DOMBUS_MASK)) << 16;
++ tag |= (devnum & 0x00001fu) << 11;
++ tag |= (funcnum & 0x000007u) << 8;
++
++ return tag;
++}
++#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 12 */
++
+ #ifndef XSERVER_LIBPCIACCESS
+
+ /* pciVideoPtr */
+diff --git a/src/cir_shadow.c b/src/cir_shadow.c
+index b89890a..0716a64 100644
+--- a/src/cir_shadow.c
++++ b/src/cir_shadow.c
+@@ -1,5 +1,3 @@
+-/* $XFree86: Exp $ */
+-
+ /*
+ Copyright (c) 1999,2000 The XFree86 Project Inc.
+ based on code written by Mark Vojkovich <markv@valinux.com>
+diff --git a/src/lg.h b/src/lg.h
+index 9d91053..985f634 100644
+--- a/src/lg.h
++++ b/src/lg.h
+@@ -10,8 +10,6 @@
+ * Inspired by cir.h
+ */
+
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg.h,v 1.12 2001/05/04 19:05:36 dawes Exp $ */
+-
+ #ifndef LG_H
+ #define LG_H
+ #define LG_DEBUG
+diff --git a/src/lg_driver.c b/src/lg_driver.c
+index cfc3e65..fc864f8 100644
+--- a/src/lg_driver.c
++++ b/src/lg_driver.c
+@@ -13,7 +13,6 @@
+ * David Dawes, Andrew E. Mileski, Leonard N. Zubkoff,
+ * Guy DESBIEF, Itai Nahshon.
+ */
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c,v 1.49 2003/11/03 05:11:09 tsi Exp $ */
+
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+@@ -259,7 +258,7 @@ LgFreeRec(ScrnInfoPtr pScrn)
+ {
+ if (pScrn->driverPrivate == NULL)
+ return;
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -373,7 +372,12 @@ LgPreInit(ScrnInfoPtr pScrn, int flags)
+
+ pCir = CIRPTR(pScrn);
+ pCir->pScrn = pScrn;
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ pCir->PIOReg = hwp->PIOOffset + 0x3CE;
++#else
++ pCir->PIOReg = 0x3CE;
++#endif
+
+ /* Get the entity, and make sure it is PCI. */
+ pCir->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+@@ -454,7 +458,7 @@ LgPreInit(ScrnInfoPtr pScrn, int flags)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if (!(pCir->Options = xalloc(sizeof(LgOptions))))
++ if (!(pCir->Options = malloc(sizeof(LgOptions))))
+ return FALSE;
+ memcpy(pCir->Options, LgOptions, sizeof(LgOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pCir->Options);
+@@ -1314,7 +1318,7 @@ LgScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+
+ if(pCir->shadowFB) {
+ pCir->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
+- pCir->ShadowPtr = xalloc(pCir->ShadowPitch * height);
++ pCir->ShadowPtr = malloc(pCir->ShadowPitch * height);
+ displayWidth = pCir->ShadowPitch / (pScrn->bitsPerPixel >> 3);
+ FbBase = pCir->ShadowPtr;
+ } else {
+@@ -1617,7 +1621,7 @@ LgCloseScreen(int scrnIndex, ScreenPtr pScreen)
+ xf86DestroyCursorInfoRec(pCir->CursorInfoRec);
+ pCir->CursorInfoRec = NULL;
+ if (pCir->DGAModes)
+- xfree(pCir->DGAModes);
++ free(pCir->DGAModes);
+ pCir->DGAnumModes = 0;
+ pCir->DGAModes = NULL;
+
+diff --git a/src/lg_hwcurs.c b/src/lg_hwcurs.c
+index b41b79a..381db1c 100644
+--- a/src/lg_hwcurs.c
++++ b/src/lg_hwcurs.c
+@@ -10,7 +10,6 @@
+ * Much of this code is inspired by the HW cursor code from XFree86
+ * 3.3.3.
+ */
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_hwcurs.c,v 1.4 2000/12/06 15:35:17 eich Exp $ */
+
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+diff --git a/src/lg_i2c.c b/src/lg_i2c.c
+index 05e083c..145cc2e 100644
+--- a/src/lg_i2c.c
++++ b/src/lg_i2c.c
+@@ -1,7 +1,5 @@
+ /* (c) Itai Nahshon */
+
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_i2c.c,v 1.1 1998/11/15 04:30:25 dawes Exp $ */
+-
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+diff --git a/src/lg_xaa.c b/src/lg_xaa.c
+index fd8c70a..8bab365 100644
+--- a/src/lg_xaa.c
++++ b/src/lg_xaa.c
+@@ -10,7 +10,6 @@
+ * Much of this code is inspired by the XAA acceleration from XFree86
+ * 3.3.3, laguna_acl.c
+ */
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.c,v 1.4 2000/12/06 15:35:17 eich Exp $ */
+
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+diff --git a/src/lg_xaa.h b/src/lg_xaa.h
+index 7359a49..162aa5d 100644
+--- a/src/lg_xaa.h
++++ b/src/lg_xaa.h
+@@ -13,7 +13,6 @@
+ * This header file draws much from the file cir_blitLG.h in version 3.3.3
+ * of XFree86.
+ */
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.h,v 1.3 2000/02/08 13:13:15 eich Exp $ */
+
+ /* This header file defines the necessary structures, contstants, and
+ variables for using the bitBLT engine on a Laguna family graphics
diff --git a/staging/xf86-video-dummy/PKGBUILD b/staging/xf86-video-dummy/PKGBUILD
new file mode 100644
index 000000000..0df5bbb57
--- /dev/null
+++ b/staging/xf86-video-dummy/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149844 2012-02-11 10:27:32Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-dummy
+pkgver=0.3.5
+pkgrel=1
+pkgdesc="X.org dummy video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86dgaproto')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('41cfcaec986ab13e931d260953c5a3f626fd1d2b')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-fbdev/PKGBUILD b/staging/xf86-video-fbdev/PKGBUILD
new file mode 100644
index 000000000..4b86599d1
--- /dev/null
+++ b/staging/xf86-video-fbdev/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149846 2012-02-11 10:30:01Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-fbdev
+pkgver=0.4.2
+pkgrel=6
+pkgdesc="X.org framebuffer video driver"
+arch=(i686 x86_64)
+license=('custom')
+url="http://xorg.freedesktop.org/"
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('c8562f997d56c9fec50df6ca9892f39f43ff4c2c')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-glint/PKGBUILD b/staging/xf86-video-glint/PKGBUILD
new file mode 100644
index 000000000..edbfd0c2e
--- /dev/null
+++ b/staging/xf86-video-glint/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149850 2012-02-11 10:35:50Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-glint
+pkgver=1.2.6
+pkgrel=2
+pkgdesc="X.org GLINT/Permedia video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86dgaproto')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha256sums=('d43350ed3c149576db1dbcacf5e9a30a3268a3f49742724c9151b6f1e4bd21a7')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-i128/PKGBUILD b/staging/xf86-video-i128/PKGBUILD
new file mode 100644
index 000000000..a8be76bbf
--- /dev/null
+++ b/staging/xf86-video-i128/PKGBUILD
@@ -0,0 +1,33 @@
+# $Id: PKGBUILD 149852 2012-02-11 10:41:47Z andyrtr $
+# Maintainer:Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-i128
+pkgver=1.3.4
+pkgrel=5
+pkgdesc="X.org Number 9 I128 video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ i128-1.3.4-git.patch)
+sha1sums=('d5f755dc964eaa067b4efcafafd00814a60df775'
+ 'c282f9de94ef7225f03034c9c07f40f46bd44bdc')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/i128-1.3.4-git.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-i128/i128-1.3.4-git.patch b/staging/xf86-video-i128/i128-1.3.4-git.patch
new file mode 100644
index 000000000..581ed7bb7
--- /dev/null
+++ b/staging/xf86-video-i128/i128-1.3.4-git.patch
@@ -0,0 +1,173 @@
+diff --git a/man/i128.man b/man/i128.man
+index 920d2ab..a8e2e54 100644
+--- a/man/i128.man
++++ b/man/i128.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i128/i128.man,v 1.2 2001/01/27 18:20:48 dawes Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH I128 __drivermansuffix__ __vendorversion__
+diff --git a/src/i128_driver.c b/src/i128_driver.c
+index 903a3a8..92f9d58 100644
+--- a/src/i128_driver.c
++++ b/src/i128_driver.c
+@@ -304,13 +304,13 @@ I128Probe(DriverPtr drv, int flags)
+ numDevSections, drv, &usedChips);
+
+ /* Free it since we don't need that list after this */
+- xfree(devSections);
++ free(devSections);
+
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT) {
+- xfree(usedChips);
++ free(usedChips);
+ return FALSE;
+ }
+
+@@ -340,7 +340,7 @@ I128Probe(DriverPtr drv, int flags)
+ foundScreen = TRUE;
+ }
+
+- xfree(usedChips);
++ free(usedChips);
+
+ return foundScreen;
+ }
+@@ -446,7 +446,7 @@ I128PreInit(ScrnInfoPtr pScrn, int flags)
+ int i;
+ ClockRangePtr clockRanges;
+ MessageType from;
+- IOADDRESS iobase;
++ unsigned long iobase;
+ char *ramdac = NULL;
+ CARD32 tmpl, tmph, tmp;
+ unsigned char n, m, p, mdc, df;
+@@ -558,7 +558,7 @@ I128PreInit(ScrnInfoPtr pScrn, int flags)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if (!(pI128->Options = xalloc(sizeof(I128Options))))
++ if (!(pI128->Options = malloc(sizeof(I128Options))))
+ return FALSE;
+ memcpy(pI128->Options, I128Options, sizeof(I128Options));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pI128->Options);
+@@ -650,7 +650,10 @@ I128PreInit(ScrnInfoPtr pScrn, int flags)
+ xf86DrvMsg(pScrn->scrnIndex, from, "Subsystem Vendor: \"%x\"\n",
+ PCI_SUB_VENDOR_ID(pI128->PciInfo));
+
+- iobase = (PCI_REGION_BASE(pI128->PciInfo, 5, REGION_IO) & 0xFFFFFF00) + hwp->PIOOffset;
++ iobase = (PCI_REGION_BASE(pI128->PciInfo, 5, REGION_IO) & 0xFFFFFF00);
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ iobase += hwp->PIOOffset;
++#endif
+ pI128->RegRec.iobase = iobase;
+
+ pI128->io.rbase_g = inl(iobase) & 0xFFFFFF00;
+@@ -1157,7 +1160,7 @@ I128FreeRec(ScrnInfoPtr pScrn)
+ {
+ if (pScrn->driverPrivate == NULL)
+ return;
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -1704,12 +1707,12 @@ I128CloseScreen(int scrnIndex, ScreenPtr pScreen)
+ XAADestroyInfoRec(pI128->XaaInfoRec);
+ if (pI128->ExaDriver) {
+ exaDriverFini(pScreen);
+- xfree(pI128->ExaDriver);
++ free(pI128->ExaDriver);
+ }
+ if (pI128->CursorInfoRec)
+ xf86DestroyCursorInfoRec(pI128->CursorInfoRec);
+ if (pI128->DGAModes)
+- xfree(pI128->DGAModes);
++ free(pI128->DGAModes);
+ pScrn->vtSema = FALSE;
+
+ pScreen->CloseScreen = pI128->CloseScreen;
+@@ -1804,7 +1807,7 @@ I128DDC1Read(ScrnInfoPtr pScrn)
+ I128Ptr pI128 = I128PTR(pScrn);
+ unsigned char val;
+ unsigned long tmp, ddc;
+- IOADDRESS iobase;
++ unsigned long iobase;
+
+ iobase = pI128->RegRec.iobase;
+ ddc = inl(iobase + 0x2C);
+@@ -1839,7 +1842,7 @@ I128I2CGetBits(I2CBusPtr b, int *clock, int *data)
+ {
+ I128Ptr pI128 = I128PTR(xf86Screens[b->scrnIndex]);
+ unsigned long ddc;
+- IOADDRESS iobase;
++ unsigned long iobase;
+ #if 0
+ static int lastclock = -1, lastdata = -1;
+ #endif
+@@ -1867,7 +1870,7 @@ I128I2CPutBits(I2CBusPtr b, int clock, int data)
+ unsigned char drv, val;
+ unsigned long ddc;
+ unsigned long tmp;
+- IOADDRESS iobase;
++ unsigned long iobase;
+
+ iobase = pI128->RegRec.iobase;
+ ddc = inl(iobase + 0x2C);
+@@ -1889,7 +1892,7 @@ I128I2CInit(ScrnInfoPtr pScrn)
+ {
+ I128Ptr pI128 = I128PTR(pScrn);
+ I2CBusPtr I2CPtr;
+- IOADDRESS iobase;
++ unsigned long iobase;
+ unsigned long soft_sw, ddc;
+
+ I2CPtr = xf86CreateI2CBusRec();
+@@ -2102,7 +2105,7 @@ void
+ I128DumpActiveRegisters(ScrnInfoPtr pScrn)
+ {
+ I128Ptr pI128 = I128PTR(pScrn);
+- IOADDRESS iobase;
++ unsigned long iobase;
+ unsigned long rbase_g, rbase_w, rbase_a, rbase_b, rbase_i, rbase_e;
+ unsigned long id, config1, config2, sgram, soft_sw, ddc, vga_ctl;
+ volatile CARD32 *vrba, *vrbg, *vrbw;
+diff --git a/src/i128dga.c b/src/i128dga.c
+index 48823aa..8bc2fcb 100644
+--- a/src/i128dga.c
++++ b/src/i128dga.c
+@@ -59,15 +59,15 @@ I128DGAInit(ScreenPtr pScreen)
+ while(pMode) {
+
+ if(0 /*pScrn->displayWidth != pMode->HDisplay*/) {
+- newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
++ newmodes = realloc(modes, (num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+- newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
++ newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+- xfree(modes);
++ free(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+diff --git a/src/i128reg.h b/src/i128reg.h
+index 56b9c33..a72b525 100644
+--- a/src/i128reg.h
++++ b/src/i128reg.h
+@@ -75,7 +75,7 @@ struct i128mem {
+
+ /* save the registers needed for restoration in this structure */
+ typedef struct {
+- IOADDRESS iobase; /* saved only for iobase indexing */
++ unsigned long iobase; /* saved only for iobase indexing */
+ CARD32 config1; /* iobase+0x1C register */
+ CARD32 config2; /* iobase+0x20 register */
+ CARD32 sgram; /* iobase+0x24 register */
diff --git a/staging/xf86-video-i740/PKGBUILD b/staging/xf86-video-i740/PKGBUILD
new file mode 100644
index 000000000..c6a19eab2
--- /dev/null
+++ b/staging/xf86-video-i740/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149854 2012-02-11 10:44:10Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-i740
+pkgver=1.3.2
+pkgrel=8
+pkgdesc="X.org Intel i740 video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('aadd2168153f780c487778e5fdda5473ed4b243d')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-intel/PKGBUILD b/staging/xf86-video-intel/PKGBUILD
new file mode 100644
index 000000000..1c4e20b71
--- /dev/null
+++ b/staging/xf86-video-intel/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149856 2012-02-11 10:48:04Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-intel
+pkgver=2.17.0
+pkgrel=3
+pkgdesc="X.org Intel i810/i830/i915/945G/G965+ video drivers"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('intel-dri' 'libxvmc' 'libpciaccess' 'libdrm' 'xcb-util>=0.3.8' 'libxfixes' 'udev')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libx11' 'libdrm' 'xf86driproto' 'glproto' 'mesa' 'libxvmc' 'libxrender')
+conflicts=('xorg-server<1.11.99.903' 'xf86-video-i810' 'xf86-video-intel-legacy')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('04ad9fa1f4c4e0a90f48752a709bf14700c864af')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr --enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-mach64/PKGBUILD b/staging/xf86-video-mach64/PKGBUILD
new file mode 100644
index 000000000..8619cf6d8
--- /dev/null
+++ b/staging/xf86-video-mach64/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149858 2012-02-11 10:54:56Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-mach64
+pkgver=6.9.0
+pkgrel=3
+pkgdesc="X.org mach64 video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libdrm' 'xf86driproto' 'mesa>=8.0') # 'glproto')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('95a7ec9761fe11dadbcd9078c55148198a91b2f1')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-mga/PKGBUILD b/staging/xf86-video-mga/PKGBUILD
new file mode 100644
index 000000000..0504c895a
--- /dev/null
+++ b/staging/xf86-video-mga/PKGBUILD
@@ -0,0 +1,34 @@
+# $Id: PKGBUILD 149860 2012-02-11 10:57:51Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-mga
+pkgver=1.4.13
+pkgrel=5
+pkgdesc="X.org mga video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libdrm' 'xf86driproto' 'mesa>=8.0') # 'glproto')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ git-fixes.patch)
+sha1sums=('55aa185cf381def4b5905c8b93694b8dfbd5c378'
+ '74782a39533ef475bd02b8b4645775879494e568')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i "${srcdir}/git-fixes.patch"
+ ./configure --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-mga/git-fixes.patch b/staging/xf86-video-mga/git-fixes.patch
new file mode 100644
index 000000000..3534342e6
--- /dev/null
+++ b/staging/xf86-video-mga/git-fixes.patch
@@ -0,0 +1,800 @@
+diff --git a/man/Makefile.am b/man/Makefile.am
+index b3688ce..1ea26b3 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,5 +1,5 @@
+ #
+-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
++# Copyright (c) 2005, Oracle and/or its affiliates. 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"),
+@@ -19,7 +19,7 @@
+ # 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.
+-#
++#
+
+ drivermandir = $(DRIVER_MAN_DIR)
+
+diff --git a/man/mga.man b/man/mga.man
+index 3a7a9f8..e1e674f 100644
+--- a/man/mga.man
++++ b/man/mga.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.man,v 1.7 2003/04/03 07:11:03 herrb Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH mga __drivermansuffix__ __vendorversion__
+diff --git a/src/binding.h b/src/binding.h
+index 6dcd1e9..57e9b92 100644
+--- a/src/binding.h
++++ b/src/binding.h
+@@ -13,7 +13,6 @@
+ @end
+
+ ***************************************************************************************/
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/HALlib/binding.h,v 1.3 2000/10/24 22:45:08 dawes Exp $ */
+
+ #ifndef _BINDING
+ #define _BINDING
+diff --git a/src/mga.h b/src/mga.h
+index 2cb3d88..c520e86 100644
+--- a/src/mga.h
++++ b/src/mga.h
+@@ -1,4 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.87tsi Exp $ */
+ /*
+ * MGA Millennium (MGA2064W) functions
+ *
+@@ -137,6 +136,10 @@ void MGAdbg_outreg32(ScrnInfoPtr, int,int, char*);
+ #define PCI_CHIP_MGAG200_EH_PCI 0x0533
+ #endif
+
++#ifndef PCI_CHIP_MGAG200_ER_PCI
++#define PCI_CHIP_MGAG200_ER_PCI 0x0534
++#endif
++
+ /*
+ * Read/write to the DAC via MMIO
+ */
+@@ -200,7 +203,9 @@ void MGAdbg_outreg32(ScrnInfoPtr, int,int, char*);
+ typedef struct {
+ unsigned char ExtVga[6];
+ unsigned char DacClk[6];
+- unsigned char * DacRegs;
++ unsigned char ExtVga_Index24;
++ unsigned char Dac_Index90;
++ unsigned char * DacRegs;
+ unsigned long crtc2[0x58];
+ unsigned char dac2[0x21];
+ CARD32 Option;
+@@ -479,6 +484,7 @@ typedef struct {
+ int is_G200WB:1;
+ int is_G200EV:1;
+ int is_G200EH:1;
++ int is_G200ER:1;
+
+ int KVM;
+
+diff --git a/src/mga_common.h b/src/mga_common.h
+index 90f6b37..81be2bc 100644
+--- a/src/mga_common.h
++++ b/src/mga_common.h
+@@ -25,8 +25,6 @@
+ * Converted to common header format:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+- * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_common.h,v 1.2 2002/12/16 16:19:18 dawes Exp $
+- *
+ */
+
+ #ifndef _MGA_COMMON_H_
+diff --git a/src/mga_dacG.c b/src/mga_dacG.c
+index df00765..fca1031 100644
+--- a/src/mga_dacG.c
++++ b/src/mga_dacG.c
+@@ -444,6 +444,116 @@ MGAG200WBPIXPLLSET(ScrnInfoPtr pScrn, MGARegPtr mgaReg)
+ outMGAdac(MGA1064_REMHEADCTL, ucTempByte);
+ }
+
++#define G200ER_PLLREF 48000
++#define G200ER_VCOMIN 1056000
++#define G200ER_VCOMAX 1488000
++
++static void MGAG200ERComputePLLParam(ScrnInfoPtr pScrn, long lFo, int *piM, int *piN, int *piP)
++{
++
++ int ulM;
++ int ulN;
++ int ulO;
++ int ulR;
++
++ CARD32 ulComputedFo;
++ CARD32 ulVco;
++ CARD32 ulFDelta;
++ CARD32 ulFTmpDelta;
++
++ CARD32 aulMDivValue[] = {1, 2, 4, 8};
++
++ CARD32 ulFo = lFo;
++
++ ulFDelta = 0xFFFFFFFF;
++
++ for (ulR = 0; ulR < 4; ulR++)
++ {
++ if(ulFDelta==0) break;
++ for (ulN = 5; (ulN <= 128) ; ulN++)
++ {
++ if(ulFDelta==0) break;
++ for (ulM = 3; ulM >= 0; ulM--)
++ {
++ if(ulFDelta==0) break;
++ for (ulO = 5; ulO <= 32; ulO++)
++ {
++ ulVco = (G200ER_PLLREF * (ulN+1)) / (ulR+1);
++ // Validate vco
++ if (ulVco < G200ER_VCOMIN) continue;
++ if (ulVco > G200ER_VCOMAX) continue;
++ ulComputedFo = ulVco / (aulMDivValue[ulM] * (ulO+1));
++
++ if (ulComputedFo > ulFo)
++ {
++ ulFTmpDelta = ulComputedFo - ulFo;
++ }
++ else
++ {
++ ulFTmpDelta = ulFo - ulComputedFo;
++ }
++
++ if (ulFTmpDelta < ulFDelta)
++ {
++ ulFDelta = ulFTmpDelta;
++ // XG200ERPIXPLLCM M<1:0> O<7:3>
++ *piM = (CARD8)ulM | (CARD8)(ulO<<3);
++ //
++ // XG200ERPIXPLLCN N<6:0>
++ *piN = (CARD8)ulN;
++ //
++ // XG200ERPIXPLLCP R<1:0> cg<7:4> (Use R value)
++ *piP = (CARD8)ulR | (CARD8)(ulR<<3);
++
++ // Test
++ int ftest = (G200ER_PLLREF * (ulN+1)) / ((ulR+1) * aulMDivValue[ulM] * (ulO+1));
++ ftest=ftest;
++ }
++ } // End O Loop
++ } // End M Loop
++ } // End N Loop
++ } // End R Loop
++}
++
++static void
++MGAG200ERPIXPLLSET(ScrnInfoPtr pScrn, MGARegPtr mgaReg)
++{
++ //TODO G200ER Validate sequence
++ CARD8 ucPixCtrl, ucTempByte;
++ MGAPtr pMga = MGAPTR(pScrn);
++
++
++ // Set pixclkdis to 1
++ ucPixCtrl = inMGAdac(MGA1064_PIX_CLK_CTL);
++ ucPixCtrl |= MGA1064_PIX_CLK_CTL_CLK_DIS;
++ outMGAdac(MGA1064_PIX_CLK_CTL, ucPixCtrl);
++
++ ucTempByte = inMGAdac(MGA1064_REMHEADCTL);
++ ucTempByte |= MGA1064_REMHEADCTL_CLKDIS;
++ outMGAdac(MGA1064_REMHEADCTL, ucTempByte);
++
++ // Select PLL Set C
++ ucTempByte = INREG8(MGAREG_MEM_MISC_READ);
++ ucTempByte |= (0x3<<2) | 0xc0; //select MGA pixel clock
++ OUTREG8(MGAREG_MEM_MISC_WRITE, ucTempByte);
++
++ ucPixCtrl &= ~MGA1064_PIX_CLK_CTL_CLK_DIS;
++ ucPixCtrl |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN;
++ outMGAdac(MGA1064_PIX_CLK_CTL, ucPixCtrl);
++
++ // Wait 500 us
++ usleep(500);
++
++ // Program the Pixel PLL Register
++ outMGAdac(MGA1064_ER_PIX_PLLC_N, mgaReg->PllN);
++ outMGAdac(MGA1064_ER_PIX_PLLC_M, mgaReg->PllM);
++ outMGAdac(MGA1064_ER_PIX_PLLC_P, mgaReg->PllP);
++
++ // Wait 50 us
++ usleep(50);
++
++}
++
+ static void
+ MGAG200WBPrepareForModeSwitch(ScrnInfoPtr pScrn)
+ {
+@@ -768,8 +878,13 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out )
+
+ pReg->PllM = m;
+ pReg->PllN = n;
+- pReg->PllP = p;
+- } else {
++ pReg->PllP = p;
++ } else if (pMga->is_G200ER) {
++ MGAG200ERComputePLLParam(pScrn, f_out, &m, &n, &p);
++ pReg->PllM = m;
++ pReg->PllN = n;
++ pReg->PllP = p;
++ } else {
+ /* Do the calculations for m, n, p and s */
+ MGAGCalcClock( pScrn, f_out, &m, &n, &p, &s );
+
+@@ -966,6 +1081,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+ pReg->Option2 = 0x0000b000;
+ break;
+
++ case PCI_CHIP_MGAG200_ER_PCI:
++ pReg->Dac_Index90 = 0;
++ break;
++
+ case PCI_CHIP_MGAG200_EH_PCI:
+ pReg->DacRegs[MGA1064_MISC_CTL] =
+ MGA1064_MISC_CTL_VGA8 |
+@@ -1088,6 +1207,7 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+ if (pMga->is_G200WB){
+ pReg->ExtVga[1] |= 0x88;
+ }
++ pReg->ExtVga_Index24 = 0x05;
+
+ pVga->CRTC[0] = ht - 4;
+ pVga->CRTC[1] = hd;
+@@ -1327,10 +1447,15 @@ MGA_NOT_HAL(
+ if ( (pMga->is_G200EV || pMga->is_G200WB || pMga->is_G200EH) &&
+ (i >= 0x44) && (i <= 0x4E))
+ continue;
+-
++
+ outMGAdac(i, mgaReg->DacRegs[i]);
+ }
+
++ if (pMga->is_G200ER)
++ {
++ outMGAdac(0x90, mgaReg->Dac_Index90);
++ }
++
+ if (!MGAISGx50(pMga)) {
+ /* restore pci_option register */
+ #ifdef XSERVER_LIBPCIACCESS
+@@ -1361,7 +1486,9 @@ MGA_NOT_HAL(
+ #endif
+ }
+
+- if (pMga->is_G200EV) {
++ if (pMga->is_G200ER) {
++ MGAG200ERPIXPLLSET(pScrn, mgaReg);
++ } else if (pMga->is_G200EV) {
+ MGAG200EVPIXPLLSET(pScrn, mgaReg);
+ } else if (pMga->is_G200WB) {
+ MGAG200WBPIXPLLSET(pScrn, mgaReg);
+@@ -1388,6 +1515,11 @@ MGA_NOT_HAL(
+ for (i = 0; i < 6; i++)
+ OUTREG16(MGAREG_CRTCEXT_INDEX, (mgaReg->ExtVga[i] << 8) | i);
+
++ if (pMga->is_G200ER) {
++ OUTREG8(MGAREG_CRTCEXT_INDEX, 0x24);
++ OUTREG8(MGAREG_CRTCEXT_DATA, mgaReg->ExtVga_Index24);
++ }
++
+ /* This handles restoring the generic VGA registers. */
+ if (pMga->is_G200SE) {
+ MGAG200SERestoreMode(pScrn, vgaReg);
+@@ -1404,7 +1536,7 @@ MGA_NOT_HAL(
+ OUTREG16(MGAREG_CRTCEXT_INDEX, 6);
+ OUTREG16(MGAREG_CRTCEXT_DATA, 0);
+ }
+-
++
+ /*
+ * this is needed to properly restore start address
+ */
+@@ -1555,6 +1687,11 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
+ mgaReg->PllM = inMGAdac(MGA1064_EH_PIX_PLLC_M);
+ mgaReg->PllN = inMGAdac(MGA1064_EH_PIX_PLLC_N);
+ mgaReg->PllP = inMGAdac(MGA1064_EH_PIX_PLLC_P);
++ } else if (pMga->is_G200ER) {
++ mgaReg->PllM = inMGAdac(MGA1064_ER_PIX_PLLC_M);
++ mgaReg->PllN = inMGAdac(MGA1064_ER_PIX_PLLC_N);
++ mgaReg->PllP = inMGAdac(MGA1064_ER_PIX_PLLC_P);
++ mgaReg->Dac_Index90 = inMGAdac(0x90);
+ }
+
+ mgaReg->PIXPLLCSaved = TRUE;
+@@ -1583,6 +1720,11 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
+ OUTREG8(MGAREG_CRTCEXT_INDEX, i);
+ mgaReg->ExtVga[i] = INREG8(MGAREG_CRTCEXT_DATA);
+ }
++ if (pMga->is_G200ER)
++ {
++ OUTREG8(MGAREG_CRTCEXT_INDEX, 0x24);
++ mgaReg->ExtVga_Index24 = INREG8(MGAREG_CRTCEXT_DATA);
++ }
+
+ #ifdef DEBUG
+ ErrorF("Saved values:\nDAC:");
+@@ -1737,7 +1879,7 @@ static const struct mgag_i2c_private {
+ { (1 << 0), (1 << 2) },
+ { (1 << 4), (1 << 5) },
+ { (1 << 0), (1 << 1) }, /* G200SE, G200EV and G200WB I2C bits */
+- { (1 << 1), (1 << 0) }, /* G200EH I2C bits */
++ { (1 << 1), (1 << 0) }, /* G200EH, G200ER I2C bits */
+ };
+
+
+@@ -1750,7 +1892,7 @@ MGAG_ddc1Read(ScrnInfoPtr pScrn)
+
+ if (pMga->is_G200SE || pMga->is_G200WB || pMga->is_G200EV)
+ i2c_index = 3;
+- else if (pMga->is_G200EH)
++ else if (pMga->is_G200EH || pMga->is_G200ER)
+ i2c_index = 4;
+ else
+ i2c_index = 0;
+@@ -1851,7 +1993,7 @@ MGAG_i2cInit(ScrnInfoPtr pScrn)
+
+ if (pMga->is_G200SE || pMga->is_G200WB || pMga->is_G200EV)
+ i2c_index = 3;
+- else if (pMga->is_G200EH)
++ else if (pMga->is_G200EH || pMga->is_G200ER)
+ i2c_index = 4;
+ else
+ i2c_index = 0;
+@@ -1976,7 +2118,7 @@ void MGAGSetupFuncs(ScrnInfoPtr pScrn)
+ pMga->Save = MGAGSave;
+ pMga->Restore = MGAGRestore;
+ pMga->ModeInit = MGAGInit;
+- if (!pMga->is_G200WB){
++ if ((!pMga->is_G200WB) && (!pMga->is_G200ER)) {
+ pMga->ddc1Read = MGAG_ddc1Read;
+ /* vgaHWddc1SetSpeed will only work if the card is in VGA mode */
+ pMga->DDC1SetSpeed = vgaHWddc1SetSpeedWeak();
+diff --git a/src/mga_dri.c b/src/mga_dri.c
+index 3fda623..14f342f 100644
+--- a/src/mga_dri.c
++++ b/src/mga_dri.c
+@@ -32,7 +32,6 @@
+
+ #include "xf86.h"
+ #include "xf86_OSproc.h"
+-#include "xf86Priv.h"
+
+ #include "xf86PciInfo.h"
+ #include "xf86Pci.h"
+diff --git a/src/mga_dri.h b/src/mga_dri.h
+index f1afb5d..1984b9c 100644
+--- a/src/mga_dri.h
++++ b/src/mga_dri.h
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h,v 1.6 2001/04/10 16:08:01 dawes Exp $ */
+-
+ /*
+ * Copyright 2000 VA Linux Systems Inc., Fremont, California.
+ * All Rights Reserved.
+diff --git a/src/mga_dripriv.h b/src/mga_dripriv.h
+index 3ddd133..feca134 100644
+--- a/src/mga_dripriv.h
++++ b/src/mga_dripriv.h
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dripriv.h,v 1.4 2001/04/10 16:08:01 dawes Exp $ */
+-
+ /*
+ * Copyright 2000 VA Linux Systems Inc., Fremont, California.
+ * All Rights Reserved.
+diff --git a/src/mga_driver.c b/src/mga_driver.c
+index 5a1e9b4..b140013 100644
+--- a/src/mga_driver.c
++++ b/src/mga_driver.c
+@@ -1,4 +1,3 @@
+-/* $XConsortium: mga_driver.c /main/12 1996/10/28 05:13:26 kaleb $ */
+ /*
+ * MGA Millennium (MGA2064W) with Ti3026 RAMDAC driver v.1.1
+ *
+@@ -404,6 +403,21 @@ static const struct mga_device_attributes attribs[] = {
+ 8192, 0x4000, /* Memory probe size & offset values */
+ },
+
++ /* G200ER */
++ [15] = { 0, 1, 0, 0, 1, 0, 0, 0, new_BARs,
++ (TRANSC_SOLID_FILL | TWO_PASS_COLOR_EXPAND | USE_LINEAR_EXPANSION),
++ {
++ { 50000, 230000 }, /* System VCO frequencies */
++ { 50000, 203400 }, /* Pixel VCO frequencies */
++ { 0, 0 }, /* Video VCO frequencies */
++ 45000, /* Memory clock */
++ 27050, /* PLL reference frequency */
++ 0, /* Supports fast bitblt? */
++ MGA_HOST_PCI /* Host interface */
++ },
++
++ 16384, 0x4000, /* Memory probe size & offset values */
++ }
+ };
+
+ #ifdef XSERVER_LIBPCIACCESS
+@@ -433,6 +447,8 @@ static const struct pci_id_match mga_device_match[] = {
+
+ MGA_DEVICE_MATCH( PCI_CHIP_MGAG200_EH_PCI, 14 ),
+
++ MGA_DEVICE_MATCH(PCI_CHIP_MGAG200_ER_PCI, 15 ),
++
+ { 0, 0, 0 },
+ };
+ #endif
+@@ -450,6 +466,7 @@ static SymTabRec MGAChipsets[] = {
+ { PCI_CHIP_MGAG200_SE_A_PCI, "mgag200 SE A PCI" },
+ { PCI_CHIP_MGAG200_SE_B_PCI, "mgag200 SE B PCI" },
+ { PCI_CHIP_MGAG200_EV_PCI, "mgag200 EV Maxim" },
++ { PCI_CHIP_MGAG200_ER_PCI, "mgag200 ER SH7757" },
+ { PCI_CHIP_MGAG200_WINBOND_PCI, "mgag200 eW Nuvoton" },
+ { PCI_CHIP_MGAG200_EH_PCI, "mgag200eH" },
+ { PCI_CHIP_MGAG400, "mgag400" },
+@@ -472,6 +489,8 @@ static PciChipsets MGAPciChipsets[] = {
+ RES_SHARED_VGA },
+ { PCI_CHIP_MGAG200_EV_PCI, PCI_CHIP_MGAG200_EV_PCI,
+ RES_SHARED_VGA },
++ { PCI_CHIP_MGAG200_ER_PCI, PCI_CHIP_MGAG200_ER_PCI,
++ RES_SHARED_VGA },
+ { PCI_CHIP_MGAG200_WINBOND_PCI, PCI_CHIP_MGAG200_WINBOND_PCI,
+ RES_SHARED_VGA },
+ { PCI_CHIP_MGAG200_EH_PCI, PCI_CHIP_MGAG200_EH_PCI,
+@@ -913,6 +932,11 @@ MGAProbe(DriverPtr drv, int flags)
+ case PCI_CHIP_MGAG200_EH_PCI:
+ attrib_no = 14;
+ break;
++
++ case PCI_CHIP_MGAG200_ER_PCI:
++ attrib_no = 15;
++ break;
++
+
+ default:
+ return FALSE;
+@@ -1081,7 +1105,7 @@ MGACountRam(ScrnInfoPtr pScrn)
+
+ if (pMga->is_G200SE)
+ pMga->reg_1e24 = INREG(0x1e24); /* stash the model for later */
+- if (pMga->reg_1e24 == 0x01) {
++ if (pMga->reg_1e24 >= 0x01) {
+ MGAUnmapMem(pScrn);
+ ProbeSize = 16384;
+ ProbeSizeOffset = 0x10000;
+@@ -1286,6 +1310,11 @@ MGAdoDDC(ScrnInfoPtr pScrn)
+ MGASave(pScrn);
+
+ /* It is now safe to talk to the card */
++ /* Allow access to DDC */
++ if (pMga->is_G200ER) {
++ CARD8 ucData = inMGAdac(MGA1064_GEN_IO_CTL2);
++ outMGAdac(MGA1064_GEN_IO_CTL2, ucData | 1);
++ }
+
+ /* Initialize I2C buses - used by DDC if available */
+ if (pMga->i2cInit) {
+@@ -1327,6 +1356,12 @@ MGAdoDDC(ScrnInfoPtr pScrn)
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of monitor info\n");
+ }
+
++ /* Remove access to DDC */
++ if (pMga->is_G200ER) {
++ CARD8 ucData = inMGAdac(MGA1064_GEN_IO_CTL2);
++ outMGAdac(MGA1064_GEN_IO_CTL2, ucData & ~1);
++ }
++
+ /* Restore previous state and unmap MGA memory and MMIO areas */
+ MGARestore(pScrn);
+ MGAUnmapMem(pScrn);
+@@ -1620,6 +1655,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
+ pMga->is_G200EV = (pMga->Chipset == PCI_CHIP_MGAG200_EV_PCI);
+ pMga->is_G200WB = (pMga->Chipset == PCI_CHIP_MGAG200_WINBOND_PCI);
+ pMga->is_G200EH = (pMga->Chipset == PCI_CHIP_MGAG200_EH_PCI);
++ pMga->is_G200ER = (pMga->Chipset == PCI_CHIP_MGAG200_ER_PCI);
+
+ #ifdef USEMGAHAL
+ if (pMga->chip_attribs->HAL_chipset) {
+@@ -1780,15 +1816,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
+ #ifndef XSERVER_LIBPCIACCESS
+ /*
+ * Find the BIOS base. Get it from the PCI config if possible. Otherwise
+- * use the VGA default. Allow the config file to override this.
++ * use the VGA default.
+ */
+
+- pMga->BiosFrom = X_NONE;
+- if (pMga->device->BiosBase != 0) {
+- /* XXX This isn't used */
+- pMga->BiosAddress = pMga->device->BiosBase;
+- pMga->BiosFrom = X_CONFIG;
+- } else {
+ /* details: rombase sdk pp 4-15 */
+ if (pMga->PciInfo->biosBase != 0) {
+ pMga->BiosAddress = pMga->PciInfo->biosBase & 0xffff0000;
+@@ -1797,7 +1827,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
+ pMga->BiosAddress = 0xc0000;
+ pMga->BiosFrom = X_DEFAULT;
+ }
+- }
+ if (pMga->BiosAddress) {
+ xf86DrvMsg(pScrn->scrnIndex, pMga->BiosFrom, "BIOS at 0x%lX\n",
+ (unsigned long)pMga->BiosAddress);
+@@ -2142,6 +2171,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
++ case PCI_CHIP_MGAG200_ER_PCI:
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG550:
+ MGAGSetupFuncs(pScrn);
+@@ -2255,6 +2285,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
++ case PCI_CHIP_MGAG200_ER_PCI:
+ pMga->SrcOrg = 0;
+ pMga->DstOrg = 0;
+ break;
+@@ -2432,16 +2463,17 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
+ maxPitch = 2048;
+ break;
+ case PCI_CHIP_MGAG200_SE_A_PCI:
+- if (pScrn->videoRam < 2048){
++ if (pScrn->videoRam < 2048){
+ maxPitch = 1280;
+- }
+- break;
++ }
++ break;
+ case PCI_CHIP_MGAG200:
+ case PCI_CHIP_MGAG200_PCI:
+ case PCI_CHIP_MGAG200_SE_B_PCI:
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
++ case PCI_CHIP_MGAG200_ER_PCI:
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG550:
+ maxPitch = 4096;
+@@ -3250,15 +3282,71 @@ MGA_HAL(
+ outb(0xfac, 0x02);
+ }
+
+- MGA_NOT_HAL(
+- if (pMga->is_G200SE) {
++ /*
++ This function optimize the Priority Request control
++ Higher HiPriLvl will reduce drawing performance
++ We need to give enough bandwith to crtc to avoid visual artifact
++ */
++ if (pMga->is_G200SE)
++ {
++ if (pMga->reg_1e24 >= 0x02)
++ {
++ /* Calulate CRTC Priority value */
++ CARD8 ucHiPriLvl;
++ CARD32 ulBitsPerPixel;
++ CARD32 ulMemoryBandwidth;
++
++ /* uiBitsPerPixel can only be 8,16 or32 */
++ if (pScrn->bitsPerPixel > 16)
++ {
++ ulBitsPerPixel = 32;
++ }
++ else if (pScrn->bitsPerPixel > 8)
++ {
++ ulBitsPerPixel = 16;
++ }
++ else
++ {
++ ulBitsPerPixel = 8;
++ }
++
++
++ ulMemoryBandwidth = (mode->Clock * ulBitsPerPixel) / 1000;
++
++ if (ulMemoryBandwidth > 3100) ucHiPriLvl = 0;
++ else if (ulMemoryBandwidth > 2600) ucHiPriLvl = 1;
++ else if (ulMemoryBandwidth > 1900) ucHiPriLvl = 2;
++ else if (ulMemoryBandwidth > 1160) ucHiPriLvl = 3;
++ else if (ulMemoryBandwidth > 440) ucHiPriLvl = 4;
++ else ucHiPriLvl = 5;
++
+ OUTREG8(0x1FDE, 0x06);
+- if (pMga->reg_1e24 == 0x01)
+- OUTREG8(0x1FDF, 0x03);
+- else
+- OUTREG8(0x1FDF, 0x14);
++ OUTREG8(0x1FDF, ucHiPriLvl);
++
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock == %d\n", mode->Clock);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BitsPerPixel == %d\n", pScrn->bitsPerPixel);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MemoryBandwidth == %d\n", ulMemoryBandwidth);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HiPriLvl == %02X\n", ucHiPriLvl);
+ }
+- );
++ else
++ {
++ MGA_NOT_HAL(
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock == %d\n", mode->Clock);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BitsPerPixel == %d\n", pScrn->bitsPerPixel);
++ OUTREG8(0x1FDE, 0x06);
++ if (pMga->reg_1e24 >= 0x01)
++ {
++ OUTREG8(0x1FDF, 0x03);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HiPriLvl == 03\n");
++ }
++ else
++ {
++ OUTREG8(0x1FDF, 0x14);
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HiPriLvl == 14h\n");
++ }
++ );
++ }
++ }
+
+ pMga->CurrentLayout.mode = mode;
+
+@@ -4322,13 +4410,23 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ if (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) {
+- if (mode->HDisplay > 1600)
+- return MODE_VIRTUAL_X;
+- if (mode->VDisplay > 1200)
+- return MODE_VIRTUAL_Y;
+- if (pMga->reg_1e24 == 0x01 &&
+- xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 244)
+- return MODE_BANDWIDTH;
++ if (pMga->reg_1e24 == 0x01) {
++ if (mode->HDisplay > 1600)
++ return MODE_VIRTUAL_X;
++ if (mode->VDisplay > 1200)
++ return MODE_VIRTUAL_Y;
++ if (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 244)
++ return MODE_BANDWIDTH;
++ } else {
++ if (pMga->reg_1e24 >= 0x02) {
++ if (mode->HDisplay > 1920)
++ return MODE_VIRTUAL_X;
++ if (mode->VDisplay > 1200)
++ return MODE_VIRTUAL_Y;
++ if (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 301)
++ return MODE_BANDWIDTH;
++ }
++ }
+ } else if (pMga->is_G200WB){
+ if (mode->Flags & V_DBLSCAN)
+ return MODE_NO_DBLESCAN;
+@@ -4340,10 +4438,13 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+ return MODE_BANDWIDTH;
+ } else if (pMga->is_G200EV
+ && (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 327)) {
+- return MODE_BANDWIDTH;
++ return MODE_BANDWIDTH;
+ } else if (pMga->is_G200EH
+ && (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 375)) {
+ return MODE_BANDWIDTH;
++ } else if (pMga->is_G200ER
++ && (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 550)) {
++ return MODE_BANDWIDTH;
+ }
+
+ lace = 1 + ((mode->Flags & V_INTERLACE) != 0);
+diff --git a/src/mga_macros.h b/src/mga_macros.h
+index 69dc8e3..bffd063 100644
+--- a/src/mga_macros.h
++++ b/src/mga_macros.h
+@@ -1,5 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.21 2001/09/26 12:59:17 alanh Exp $ */
+-
+ #ifndef _MGA_MACROS_H_
+ #define _MGA_MACROS_H_
+
+diff --git a/src/mga_merge.c b/src/mga_merge.c
+index 753f752..1fd0572 100644
+--- a/src/mga_merge.c
++++ b/src/mga_merge.c
+@@ -363,6 +363,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
++ case PCI_CHIP_MGAG200_ER_PCI:
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG550:
+ MGAGSetupFuncs(pScrn);
+@@ -518,6 +519,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
++ case PCI_CHIP_MGAG200_ER_PCI:
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG550:
+ maxPitch = 4096;
+diff --git a/src/mga_reg.h b/src/mga_reg.h
+index 6251976..5a37db6 100644
+--- a/src/mga_reg.h
++++ b/src/mga_reg.h
+@@ -1,11 +1,3 @@
+-/* $XConsortium: mgareg.h /main/2 1996/10/25 10:33:21 kaleb $ */
+-
+-
+-
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.18 2001/09/26 12:59:18 alanh Exp $ */
+-
+-
+-
+ /*
+ * MGA Millennium (MGA2064W) functions
+ * MGA Mystique (MGA1064SG) functions
+@@ -377,6 +369,7 @@
+ #define MGA1064_MISC_CTL_VGA8 ( 0x01 << 3 )
+ #define MGA1064_MISC_CTL_DAC_RAM_CS ( 0x01 << 4 )
+
++#define MGA1064_GEN_IO_CTL2 0x29
+ #define MGA1064_GEN_IO_CTL 0x2a
+ #define MGA1064_GEN_IO_DATA 0x2b
+ #define MGA1064_SYS_PLL_M 0x2c
+@@ -437,6 +430,10 @@
+ #define MGA1064_EH_PIX_PLLC_N 0xb7
+ #define MGA1064_EH_PIX_PLLC_P 0xb8
+
++/* Modified PLL for G200 Maxim (G200ER) */
++#define MGA1064_ER_PIX_PLLC_M 0xb7
++#define MGA1064_ER_PIX_PLLC_N 0xb6
++#define MGA1064_ER_PIX_PLLC_P 0xb8
+
+ #define MGA1064_DISP_CTL 0x8a
+ #define MGA1064_DISP_CTL_DAC1OUTSEL_MASK 0x01
+diff --git a/src/mga_sarea.h b/src/mga_sarea.h
+index c5ffbbc..16fc9ce 100644
+--- a/src/mga_sarea.h
++++ b/src/mga_sarea.h
+@@ -1,5 +1,3 @@
+-/* $XFree86$ */
+-
+ /*
+ * Copyright 2000 Gareth Hughes
+ * All Rights Reserved.
+diff --git a/src/mga_storm.c b/src/mga_storm.c
+index 87473c8..db7fae7 100644
+--- a/src/mga_storm.c
++++ b/src/mga_storm.c
+@@ -1131,6 +1131,7 @@ void MGAStormEngineInit( ScrnInfoPtr pScrn )
+ case PCI_CHIP_MGAG200_WINBOND_PCI:
+ case PCI_CHIP_MGAG200_EV_PCI:
+ case PCI_CHIP_MGAG200_EH_PCI:
++ case PCI_CHIP_MGAG200_ER_PCI:
+ pMga->SrcOrg = 0;
+ OUTREG(MGAREG_SRCORG, pMga->realSrcOrg);
+ OUTREG(MGAREG_DSTORG, pMga->DstOrg);
+diff --git a/src/mgareg_flags.h b/src/mgareg_flags.h
+index 69050fc..548af86 100644
+--- a/src/mgareg_flags.h
++++ b/src/mgareg_flags.h
+@@ -19,7 +19,6 @@
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mgareg_flags.h,v 1.2 2003/01/12 03:55:47 tsi Exp $ */
+
+ #ifndef _MGAREGS_H_
+ #define _MGAREGS_H_
+diff --git a/util/stormdwg.c b/util/stormdwg.c
+index 99f76cc..b43cc32 100644
+--- a/util/stormdwg.c
++++ b/util/stormdwg.c
+@@ -1,8 +1,3 @@
+-/* $XConsortium: dwg.c /main/2 1996/10/28 06:57:55 kaleb $ */
+-
+-
+-
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/util/stormdwg.c,v 1.1 1997/04/12 14:11:29 hohndel Exp $ */
+
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/staging/xf86-video-neomagic/PKGBUILD b/staging/xf86-video-neomagic/PKGBUILD
new file mode 100644
index 000000000..2436e4092
--- /dev/null
+++ b/staging/xf86-video-neomagic/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149862 2012-02-11 10:59:39Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-neomagic
+pkgver=1.2.5
+pkgrel=6
+pkgdesc="X.org neomagic video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86dgaproto')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('02c994e2eae191b50a8cd556e5b52d82725073b3')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -d -m755 "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-nv/PKGBUILD b/staging/xf86-video-nv/PKGBUILD
new file mode 100644
index 000000000..f9ff6cd10
--- /dev/null
+++ b/staging/xf86-video-nv/PKGBUILD
@@ -0,0 +1,31 @@
+# $Id: PKGBUILD 149864 2012-02-11 11:01:18Z andyrtr $
+# Maintainer:Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-nv
+pkgver=2.1.18
+pkgrel=5
+pkgdesc="X.org nv video driver"
+arch=(i686 x86_64)
+license=('custom')
+url="http://xorg.freedesktop.org/"
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('d35b2fa5a26a507a9cc95b69243d9fd0c0f32aa2')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-r128/PKGBUILD b/staging/xf86-video-r128/PKGBUILD
new file mode 100644
index 000000000..5f5568b7c
--- /dev/null
+++ b/staging/xf86-video-r128/PKGBUILD
@@ -0,0 +1,36 @@
+# $Id: PKGBUILD 149866 2012-02-11 11:05:08Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-r128
+pkgver=6.8.1
+pkgrel=8
+pkgdesc="X.org ati Rage128 video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86driproto' 'libdrm' 'mesa') # 'glproto')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ git-fixes.patch)
+md5sums=('2b90854a62a4d45d652062f582dc8d13'
+ '3937776d4427861d0797e47119ac327d')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i "${srcdir}/git-fixes.patch"
+
+ autoreconf -fi
+ ./configure --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-r128/git-fixes.patch b/staging/xf86-video-r128/git-fixes.patch
new file mode 100644
index 000000000..933e8fb2a
--- /dev/null
+++ b/staging/xf86-video-r128/git-fixes.patch
@@ -0,0 +1,842 @@
+diff --git a/COPYING b/COPYING
+index 7f33cbf..05bcb74 100644
+--- a/COPYING
++++ b/COPYING
+@@ -1,12 +1,91 @@
+-This is a stub file. This package has not yet had its complete licensing
+-information compiled. Please see the individual source files for details on
+-your rights to use and modify this software.
++Copyright 2007 George Sapountzis
+
+-Please submit updated COPYING files to the Xorg bugzilla:
++Permission is hereby granted, free of charge, to any person obtaining a
++copy of this software and associated documentation files (the "Software"),
++to deal in the Software without restriction, including without limitation
++the rights to use, copy, modify, merge, publish, distribute, sublicense,
++and/or sell copies of the Software, and to permit persons to whom the
++Software is furnished to do so, subject to the following conditions:
+
+-https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
++The above copyright notice and this permission notice (including the next
++paragraph) shall be included in all copies or substantial portions of the
++Software.
+
+-All licensing questions regarding this software should be directed at the
+-Xorg mailing list:
++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
++THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++SOFTWARE.
++
++Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
++ Precision Insight, Inc., Cedar Park, Texas, and
++ VA Linux Systems Inc., Fremont, California.
++
++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 on the rights to use, copy, modify, merge,
++publish, distribute, sublicense, and/or sell copies of the Software,
++and to permit persons to whom the Software is furnished to do so,
++subject to the following conditions:
++
++The above copyright notice and this permission notice (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 ATI, PRECISION INSIGHT, VA LINUX
++SYSTEMS AND/OR THEIR 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.
++
++Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
++Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
++All Rights Reserved.
++
++Permission is hereby granted, free of charge, to any person obtaining a
++copy of this software and associated documentation files (the "Software"),
++to deal in the Software without restriction, including without limitation
++the rights to use, copy, modify, merge, publish, distribute, sublicense,
++and/or sell copies of the Software, and to permit persons to whom the
++Software is furnished to do so, subject to the following conditions:
++
++The above copyright notice and this permission notice (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 NONINFRINGEMENT. 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.
++
++Copyright 2000 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
++
++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 name of Marc Aurele La France not be used in advertising or
++publicity pertaining to distribution of the software without specific,
++written prior permission. Marc Aurele La France makes no representations
++about the suitability of this software for any purpose. It is provided
++"as-is" without express or implied warranty.
++
++MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
++INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
++EVENT SHALL MARC AURELE LA FRANCE 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.
+
+-http://lists.freedesktop.org/mailman/listinfo/xorg
+diff --git a/Makefile.am b/Makefile.am
+index 1f4c3c4..4c278ba 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,21 +18,15 @@
+ # 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
++MAINTAINERCLEANFILES = ChangeLog INSTALL
+
+-if BUILD_LINUXDOC
+-README.r128: README.r128.sgml
+- $(MAKE_TEXT) README.r128.sgml && mv README.r128.txt README.r128
++.PHONY: ChangeLog INSTALL
+
+-endif
+-
+-EXTRA_DIST = README.r128 README.r128.sgml ChangeLog
+-CLEANFILES = ChangeLog
+-
+-.PHONY: ChangeLog
++INSTALL:
++ $(INSTALL_CMD)
+
+ ChangeLog:
+ $(CHANGELOG_CMD)
+
+-dist-hook: ChangeLog
++dist-hook: ChangeLog INSTALL
+diff --git a/README b/README
+index cb61870..5c6f59d 100644
+--- a/README
++++ b/README
+@@ -1,4 +1,161 @@
+-xf86-video-r128 - ATI Rage 128 video driver for the Xorg X server
++ Information for ATI Rage 128 Users
++ Precision Insight, Inc., SuSE GmbH
++ 13 June 2000
++ ____________________________________________________________
++
++ Table of Contents
++
++
++ 1. Supported Hardware
++ 2. Features
++ 3. Technical Notes
++ 4. Reported Working Video Cards
++ 5. Configuration
++ 6. Driver Options
++ 7. Known Limitations
++ 8. Authors
++
++
++ ______________________________________________________________________
++
++ 1. Supported Hardware
++
++
++ o ATI Rage 128 based cards
++
++
++
++ 2. Features
++
++
++ o Full support (including hardware accelerated 2D drawing) for 8, 15,
++ 16, 24 bit pixel depths.
++
++ o Hardware cursor support to reduce sprite flicker.
++
++ o Support for high resolution video modes up to 1800x1440 @ 70Hz.
++
++ o Support for doublescan video modes (e.g., 320x200 and 320x240).
++
++ o Support for gamma correction at all pixel depths.
++
++ o Fully programmable clock supported.
++
++ o Robust text mode restore for VT switching.
++
++
++
++ 3. Technical Notes
++
++
++ o None
++
++
++
++ 4. Reported Working Video Cards
++
++
++ o Rage Fury AGP 32MB
++
++ o XPERT 128 AGP 16MB
++
++ o XPERT 99 AGP 8MB
++
++
++
++ 5. Configuration
++
++ The driver auto-detects all device information necessary to initialize
++ the card. The only lines you need in the "Device" section of your
++ xorg.conf file are:
++
++ Section "Device"
++ Identifier "Rage 128"
++ Driver "r128"
++ EndSection
++
++
++ or let xorgconfig do this for you.
++
++ However, if you have problems with auto-detection, you can specify:
++
++ o VideoRam - in kilobytes
++
++ o MemBase - physical address of the linear framebuffer
++
++ o IOBase - physical address of the memory mapped IO registers
++
++ o ChipID - PCI DEVICE ID
++
++
++
++ 6. Driver Options
++
++
++ o "hw_cursor" - request hardware cursor (default)
++
++ o "sw_cursor" - software cursor only
++
++ o "no_accel" - software rendering only
++
++ o "dac_8_bit" - use color weight 888 in 8 bpp mode (default)
++
++ o "dac_6_bit" - use color weight 666 in 8 bpp mode (VGA emulation)
++
++
++
++ 7. Known Limitations
++
++
++ o None
++
++
++
++ 8. Authors
++
++ The X11R7.5 driver was originally part of XFree86 4.4 rc2.
++
++ The XFree86 4 driver was ported from XFree86 3.3.x and enhanced by:
++
++ o Rickard E. (Rik) Faith <mailto:faith@precisioninsight.com>
++
++ o Kevin E. Martin <mailto:kevin@precisioninsight.com>
++
++ The XFree86 4 driver was funded by ATI and was donated to The XFree86
++ Project by:
++
++ Precision Insight, Inc.
++ Cedar Park, TX
++ USA
++
++
++ The XFree86 3.3.x driver used for the port was written by:
++
++ o Rickard E. (Rik) Faith <mailto:faith@precisioninsight.com>
++
++ o Kevin E. Martin <mailto:kevin@precisioninsight.com>
++
++ The XFree86 3.3.x driver was funded by ATI and was donated to The
++ XFree86 Project by Precision Insight, Inc. It was based in part on
++ an earlier driver that was written by:
++
++ o Alan Hourihane <mailto:alanh@fairlite.demon.co.uk>
++
++ o Dirk Hohndel <mailto:hohndel@suse.de>
++
++ This early driver was funded and donated to The XFree86 Project by:
++
++ SuSE GmbH
++ Schanzaekerstr. 10
++ 90443 Nuernberg
++ Germany
++
++
++
++ http://www.precisioninsight.com
++
++ http://www.suse.com
++
+
+ Please submit bugs & patches to the Xorg bugzilla:
+
+diff --git a/README.r128 b/README.r128
+deleted file mode 100644
+index dcc2715..0000000
+--- a/README.r128
++++ /dev/null
+@@ -1,160 +0,0 @@
+- Information for ATI Rage 128 Users
+- Precision Insight, Inc., SuSE GmbH
+- 13 June 2000
+- ____________________________________________________________
+-
+- Table of Contents
+-
+-
+- 1. Supported Hardware
+- 2. Features
+- 3. Technical Notes
+- 4. Reported Working Video Cards
+- 5. Configuration
+- 6. Driver Options
+- 7. Known Limitations
+- 8. Authors
+-
+-
+- ______________________________________________________________________
+-
+- 1. Supported Hardware
+-
+-
+- +o ATI Rage 128 based cards
+-
+-
+-
+- 2. Features
+-
+-
+- +o Full support (including hardware accelerated 2D drawing) for 8, 15,
+- 16, 24 bit pixel depths.
+-
+- +o Hardware cursor support to reduce sprite flicker.
+-
+- +o Support for high resolution video modes up to 1800x1440 @ 70Hz.
+-
+- +o Support for doublescan video modes (e.g., 320x200 and 320x240).
+-
+- +o Support for gamma correction at all pixel depths.
+-
+- +o Fully programmable clock supported.
+-
+- +o Robust text mode restore for VT switching.
+-
+-
+-
+- 3. Technical Notes
+-
+-
+- +o None
+-
+-
+-
+- 4. Reported Working Video Cards
+-
+-
+- +o Rage Fury AGP 32MB
+-
+- +o XPERT 128 AGP 16MB
+-
+- +o XPERT 99 AGP 8MB
+-
+-
+-
+- 5. Configuration
+-
+- The driver auto-detects all device information necessary to initialize
+- the card. The only lines you need in the "Device" section of your
+- xorg.conf file are:
+-
+- Section "Device"
+- Identifier "Rage 128"
+- Driver "r128"
+- EndSection
+-
+-
+- or let xorgconfig do this for you.
+-
+- However, if you have problems with auto-detection, you can specify:
+-
+- +o VideoRam - in kilobytes
+-
+- +o MemBase - physical address of the linear framebuffer
+-
+- +o IOBase - physical address of the memory mapped IO registers
+-
+- +o ChipID - PCI DEVICE ID
+-
+-
+-
+- 6. Driver Options
+-
+-
+- +o "hw_cursor" - request hardware cursor (default)
+-
+- +o "sw_cursor" - software cursor only
+-
+- +o "no_accel" - software rendering only
+-
+- +o "dac_8_bit" - use color weight 888 in 8 bpp mode (default)
+-
+- +o "dac_6_bit" - use color weight 666 in 8 bpp mode (VGA emulation)
+-
+-
+-
+- 7. Known Limitations
+-
+-
+- +o None
+-
+-
+-
+- 8. Authors
+-
+- The X11R6.8 driver was originally part of XFree86 4.4 rc2.
+-
+- The XFree86 4 driver was ported from XFree86 3.3.x and enhanced by:
+-
+- +o Rickard E. (Rik) Faith <faith@precisioninsight.com>
+-
+- +o Kevin E. Martin <kevin@precisioninsight.com>
+-
+- The XFree86 4 driver was funded by ATI and was donated to The XFree86
+- Project by:
+-
+- Precision Insight, Inc.
+- Cedar Park, TX
+- USA
+-
+-
+- The XFree86 3.3.x driver used for the port was written by:
+-
+- +o Rickard E. (Rik) Faith <faith@precisioninsight.com>
+-
+- +o Kevin E. Martin <kevin@precisioninsight.com>
+-
+- The XFree86 3.3.x driver was funded by ATI and was donated to The
+- XFree86 Project by Precision Insight, Inc. It was based in part on
+- an earlier driver that was written by:
+-
+- +o Alan Hourihane <alanh@fairlite.demon.co.uk>
+-
+- +o Dirk Hohndel <hohndel@suse.de>
+-
+- This early driver was funded and donated to The XFree86 Project by:
+-
+- SuSE GmbH
+- Schanzaekerstr. 10
+- 90443 Nuernberg
+- Germany
+-
+-
+-
+- http://www.precisioninsight.com
+-
+- http://www.suse.com
+-
+-
+-
+diff --git a/README.r128.sgml b/README.r128.sgml
+deleted file mode 100644
+index 8d7f448..0000000
+--- a/README.r128.sgml
++++ /dev/null
+@@ -1,138 +0,0 @@
+-<!DOCTYPE linuxdoc PUBLIC "-//Xorg//DTD linuxdoc//EN"[
+-<!ENTITY % defs SYSTEM "defs.ent"> %defs;
+-]>
+-
+-<article>
+-<title>Information for ATI Rage 128 Users
+-<author>Precision Insight, Inc., SuSE GmbH
+-<date>13 June 2000
+-
+-<ident>
+-</ident>
+-
+-<toc>
+-
+-<sect>Supported Hardware
+-<p>
+-<itemize>
+- <item>ATI Rage 128 based cards
+-</itemize>
+-
+-
+-<sect>Features
+-<p>
+-<itemize>
+- <item>Full support (including hardware accelerated 2D drawing) for 8, 15,
+- 16, 24 bit pixel depths.
+- <item>Hardware cursor support to reduce sprite flicker.
+- <item>Support for high resolution video modes up to 1800x1440 @ 70Hz.
+- <item>Support for doublescan video modes (e.g., 320x200 and 320x240).
+- <item>Support for gamma correction at all pixel depths.
+- <item>Fully programmable clock supported.
+- <item>Robust text mode restore for VT switching.
+-</itemize>
+-
+-
+-<sect>Technical Notes
+-<p>
+-<itemize>
+- <item>None
+-</itemize>
+-
+-
+-<sect>Reported Working Video Cards
+-<p>
+-<itemize>
+- <item>Rage Fury AGP 32MB
+- <item>XPERT 128 AGP 16MB
+- <item>XPERT 99 AGP 8MB
+-</itemize>
+-
+-
+-<sect>Configuration
+-<p>
+-The driver auto-detects all device information necessary to
+-initialize the card. The only lines you need in the "Device"
+-section of your xorg.conf file are:
+-<verb>
+- Section "Device"
+- Identifier "Rage 128"
+- Driver "r128"
+- EndSection
+-</verb>
+-or let <tt>xorgconfig</tt> do this for you.
+-
+-However, if you have problems with auto-detection, you can specify:
+-<itemize>
+- <item>VideoRam - in kilobytes
+- <item>MemBase - physical address of the linear framebuffer
+- <item>IOBase - physical address of the memory mapped IO registers
+- <item>ChipID - PCI DEVICE ID
+-</itemize>
+-
+-
+-<sect>Driver Options
+-<p>
+-<itemize>
+- <item>"hw_cursor" - request hardware cursor (default)
+- <item>"sw_cursor" - software cursor only
+- <item>"no_accel" - software rendering only
+- <item>"dac_8_bit" - use color weight 888 in 8 bpp mode (default)
+- <item>"dac_6_bit" - use color weight 666 in 8 bpp mode (VGA emulation)
+-</itemize>
+-
+-
+-<sect>Known Limitations
+-<p>
+-<itemize>
+- <item>None
+-</itemize>
+-
+-
+-<sect>Authors
+-<p>
+-The X11R&relvers; driver was originally part of XFree86 4.4 rc2.
+-
+-The XFree86 4 driver was ported from XFree86 3.3.x and enhanced by:
+-<itemize>
+- <item>Rickard E. (Rik) Faith <email>faith@precisioninsight.com</email>
+- <item>Kevin E. Martin <email>kevin@precisioninsight.com</email>
+-</itemize>
+-<p>
+-The XFree86 4 driver was funded by ATI and was donated to The XFree86
+-Project by:
+-<verb>
+- Precision Insight, Inc.
+- Cedar Park, TX
+- USA
+-</verb>
+-<p>
+-The XFree86 3.3.x driver used for the port was written by:
+-<itemize>
+- <item>Rickard E. (Rik) Faith <email>faith@precisioninsight.com</email>
+- <item>Kevin E. Martin <email>kevin@precisioninsight.com</email>
+-</itemize>
+-The XFree86 3.3.x driver was funded by ATI and was donated to The XFree86
+-Project by Precision Insight, Inc. It was based in part on an earlier
+-driver that was written by:
+-<itemize>
+- <item>Alan Hourihane <email>alanh@fairlite.demon.co.uk</email>
+- <item>Dirk Hohndel <email>hohndel@suse.de</email>
+-</itemize>
+-<p>This early driver was funded and donated to The XFree86 Project by:
+-<verb>
+- SuSE GmbH
+- Schanzaekerstr. 10
+- 90443 Nuernberg
+- Germany
+-</verb>
+-
+-<p>
+-<htmlurl name="http://www.precisioninsight.com"
+- url="http://www.precisioninsight.com">
+-<p>
+-<htmlurl name="http://www.suse.com"
+- url="http://www.suse.com">
+-
+-
+-</article>
+diff --git a/configure.ac b/configure.ac
+index 4e0f463..d5a0821 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,28 +20,30 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-r128],
+- 6.8.1,
++ [6.8.1],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-r128)
+-
++ [xf86-video-r128])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
+-AM_INIT_AUTOMAKE([dist-bzip2])
++# Initialize Automake
++AM_INIT_AUTOMAKE([foreign dist-bzip2])
+
+-# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
+-m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.2)
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
++m4_ifndef([XORG_MACROS_VERSION],
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
++XORG_DEFAULT_OPTIONS
+
+ AM_MAINTAINER_MODE
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+
+ if test "x$GCC" = "xyes"; then
+ CPPFLAGS="$CPPFLAGS -Wall"
+@@ -49,38 +51,35 @@ fi
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-AC_ARG_ENABLE(dri, AC_HELP_STRING([--disable-dri],
++AC_ARG_ENABLE(dri, AS_HELP_STRING([--disable-dri],
+ [Disable DRI support [[default=auto]]]),
+ [DRI="$enableval"],
+ [DRI=auto])
+
+-# Checks for extensions
+-XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto)
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(XF86MISC, xf86miscproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.2 xproto fontsproto $REQUIRED_MODULES])
+ PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+ HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
+ HAVE_XEXTPROTO_71="no")
+ AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes" ])
+-sdkdir=$(pkg-config --variable=sdkdir xorg-server)
++sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
+
+ # Checks for libraries.
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+ if test "$DRI" != no; then
+ AC_CHECK_FILE([${sdkdir}/dri.h],
+ [have_dri_h="yes"], [have_dri_h="no"])
+@@ -126,26 +125,20 @@ if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+-AC_SUBST([XORG_CFLAGS])
+-AC_SUBST([DRI_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=r128
+ AC_SUBST([DRIVER_NAME])
+
+-XORG_MANPAGE_SECTIONS
+-XORG_RELEASE_VERSION
+-XORG_CHECK_LINUXDOC
+-XORG_CHANGELOG
+-
+ AC_MSG_NOTICE(
+ [Please change the Driver line in xorg.conf from "ati" to "r128" or install]
+ [the ati wrapper as well:]
+ [ git://anongit.freedesktop.org/git/xorg/driver/xf86-video-ati]
+ )
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 858ba62..4e22d61 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,27 +1,24 @@
+ #
+ # 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.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a
++# copy of this software and associated documentation files (the "Software"),
++# to deal in the Software without restriction, including without limitation
++# the rights to use, copy, modify, merge, publish, distribute, sublicense,
++# and/or sell copies of the Software, and to permit persons to whom the
++# Software is furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++# DEALINGS IN THE SOFTWARE.
+ #
+
+ drivermandir = $(DRIVER_MAN_DIR)
+@@ -34,25 +31,11 @@ EXTRA_DIST = r128.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+
+-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) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/r128.man b/man/r128.man
+index 5c7c4fe..4ba933d 100644
+--- a/man/r128.man
++++ b/man/r128.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.man,v 1.3 2001/06/01 02:10:05 dawes Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH R128 __drivermansuffix__ __vendorversion__
+diff --git a/src/r128_driver.c b/src/r128_driver.c
+index d6448b6..9d08d77 100644
+--- a/src/r128_driver.c
++++ b/src/r128_driver.c
+@@ -938,14 +938,6 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
+ /* BIOS */
+ from = X_PROBED;
+ info->BIOSAddr = info->PciInfo->biosBase & 0xfffe0000;
+- if (dev->BiosBase) {
+- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+- "BIOS address override, using 0x%08lx instead of 0x%08lx\n",
+- dev->BiosBase,
+- info->BIOSAddr);
+- info->BIOSAddr = dev->BiosBase;
+- from = X_CONFIG;
+- }
+ if (info->BIOSAddr) {
+ xf86DrvMsg(pScrn->scrnIndex, from,
+ "BIOS at 0x%08lx\n", info->BIOSAddr);
diff --git a/staging/xf86-video-rendition/PKGBUILD b/staging/xf86-video-rendition/PKGBUILD
new file mode 100644
index 000000000..70c36cc79
--- /dev/null
+++ b/staging/xf86-video-rendition/PKGBUILD
@@ -0,0 +1,35 @@
+# $Id: PKGBUILD 149868 2012-02-11 11:08:44Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-rendition
+pkgver=4.2.4
+pkgrel=6
+pkgdesc="X.org Rendition video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool' '!strip')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ rendition-4.2.4-git.patch)
+sha1sums=('16148c25183f7829c22bc9dfdb588c1a16bf4565'
+ 'e023650fa418be9a92d159acd8ac0bc23704dfb3')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/rendition-4.2.4-git.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+
+ strip --strip-unneeded "${pkgdir}/usr/lib/xorg/modules/drivers/rendition_drv.so"
+}
diff --git a/staging/xf86-video-rendition/rendition-4.2.4-git.patch b/staging/xf86-video-rendition/rendition-4.2.4-git.patch
new file mode 100644
index 000000000..26cff2fd3
--- /dev/null
+++ b/staging/xf86-video-rendition/rendition-4.2.4-git.patch
@@ -0,0 +1,809 @@
+diff --git a/configure.ac b/configure.ac
+index 5091e50..f74b912 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,45 +20,45 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-rendition],
+- 4.2.4,
++ [4.2.4],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-rendition)
+-
++ [xf86-video-rendition])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
++# Initialize Automake
+ AM_INIT_AUTOMAKE([foreign dist-bzip2])
+-
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_DEFAULT_OPTIONS
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+ m4_ifndef([XORG_MACROS_VERSION],
+- [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.3)
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
+ XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
+
+ # Checks for libraries.
+@@ -78,17 +78,16 @@ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+ # Checks for header files.
+-AC_HEADER_STDC
+ AC_CHECK_HEADERS([elf.h] [elf_abi.h])
+
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=rendition
+ AC_SUBST([DRIVER_NAME])
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 8f2454b..b3688ce 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -31,25 +31,11 @@ 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'
++
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
++
+
+ SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+ .man.$(DRIVER_MAN_SUFFIX):
+- sed $(MAN_SUBSTS) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/rendition.man b/man/rendition.man
+index 3658ab0..afeee91 100644
+--- a/man/rendition.man
++++ b/man/rendition.man
+@@ -1,4 +1,3 @@
+-.\" $__xservername__: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.man,v 1.3 2003/06/18 16:17:39 eich Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH RENDITION __drivermansuffix__ __vendorversion__
+diff --git a/src/accelX.c b/src/accelX.c
+index a499c56..ed4964e 100644
+--- a/src/accelX.c
++++ b/src/accelX.c
+@@ -289,7 +289,7 @@ int
+ RENDITIONInitUcode(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+
+ if (0 == verite_getstride(pScreenInfo, NULL,
+ &pRendition->board.mode.stride0,
+@@ -367,7 +367,7 @@ void
+ RENDITIONRestoreUcode(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+
+ vu8 memend;
+
+@@ -410,7 +410,7 @@ void
+ RENDITIONSaveUcode(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+ vu8 memend;
+
+ #ifdef DEBUG
+@@ -445,7 +445,7 @@ void
+ RENDITIONSyncV1000(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+
+ int c;
+
+@@ -555,7 +555,7 @@ RENDITIONSubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo,
+ int w, int h)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+
+
+ #ifdef DEBUG
+@@ -607,7 +607,7 @@ RENDITIONSubsequentSolidFillRect(ScrnInfoPtr pScreenInfo,
+ int x, int y, int w, int h)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+
+
+ #ifdef DEBUG
+@@ -639,7 +639,7 @@ RENDITIONSubsequentTwoPointLine(ScrnInfoPtr pScreenInfo,
+ int bias)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob = pRendition->board.io_base;
++ unsigned long iob = pRendition->board.io_base;
+
+
+ #ifdef DEBUG
+diff --git a/src/rendition.c b/src/rendition.c
+index 7a9e18b..3202b49 100644
+--- a/src/rendition.c
++++ b/src/rendition.c
+@@ -330,7 +330,7 @@ renditionProbe(DriverPtr drv, int flags)
+ renditionChipsets, renditionPCIchipsets,
+ devSections, numDevSections, drv, &usedChips);
+
+- xfree(devSections);
++ free(devSections);
+ if (numUsed <= 0)
+ return FALSE;
+
+@@ -359,7 +359,7 @@ renditionProbe(DriverPtr drv, int flags)
+ foundScreen=TRUE;
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+ }
+ return foundScreen;
+ }
+@@ -400,7 +400,7 @@ renditionGetRec(ScrnInfoPtr pScreenInfo)
+ sleep(1);
+ #endif
+ if (!pScreenInfo->driverPrivate)
+- pScreenInfo->driverPrivate=xcalloc(sizeof(renditionRec), 1);
++ pScreenInfo->driverPrivate=calloc(sizeof(renditionRec), 1);
+
+ /* perhaps some initialization? <ml> */
+
+@@ -421,7 +421,7 @@ renditionFreeRec(ScrnInfoPtr pScreenInfo)
+ #endif
+ if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
+ vgaHWFreeHWRec(pScreenInfo);
+- xfree(pScreenInfo->driverPrivate);
++ free(pScreenInfo->driverPrivate);
+ pScreenInfo->driverPrivate=NULL;
+
+ #ifdef DEBUG
+@@ -596,7 +596,7 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
+ /* collect all of the options flags and process them */
+
+ xf86CollectOptions(pScreenInfo, NULL);
+- if (!(pRendition->Options = xalloc(sizeof(renditionOptions))))
++ if (!(pRendition->Options = malloc(sizeof(renditionOptions))))
+ return FALSE;
+ memcpy(pRendition->Options, renditionOptions, sizeof(renditionOptions));
+ xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
+@@ -663,7 +663,11 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
+ vgaHWGetIOBase(pvgaHW); /* Get VGA I/O base */
+
+ pRendition->board.accel=0;
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ pRendition->board.vgaio_base = pvgaHW->PIOOffset;
++#else
++ pRendition->board.vgaio_base = 0;
++#endif
+ pRendition->board.io_base = pRendition->board.vgaio_base
+ #ifdef XSERVER_LIBPCIACCESS
+ + pRendition->PciInfo->regions[1].base_addr;
+@@ -1167,7 +1171,7 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ pRendition->board.shadowPitch
+ = BitmapBytePad(pScreenInfo->bitsPerPixel * width);
+ pRendition->board.shadowPtr
+- = xalloc(pRendition->board.shadowPitch * height);
++ = malloc(pRendition->board.shadowPitch * height);
+ displayWidth = pRendition->board.shadowPitch
+ / (pScreenInfo->bitsPerPixel >> 3);
+ FBBase = pRendition->board.shadowPtr;
+@@ -1484,7 +1488,7 @@ static xf86MonPtr
+ renditionDDC (ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base;
++ unsigned long iob=pRendition->board.io_base;
+ vu32 temp;
+
+ xf86MonPtr MonInfo = NULL;
+@@ -1517,7 +1521,7 @@ static unsigned int
+ renditionDDC1Read (ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base;
++ unsigned long iob=pRendition->board.io_base;
+ vu32 value = 0;
+
+ /* wait for Vsync */
+diff --git a/src/v1krisc.c b/src/v1krisc.c
+index 2554263..9b7b4e2 100644
+--- a/src/v1krisc.c
++++ b/src/v1krisc.c
+@@ -83,20 +83,20 @@
+ * local function prototypes
+ */
+
+-static void verite_iopoll(IOADDRESS port, vu32 data, vu32 mask);
+-static void verite_iopoll8(IOADDRESS port, vu8 data, vu8 mask);
++static void verite_iopoll(unsigned long port, vu32 data, vu32 mask);
++static void verite_iopoll8(unsigned long port, vu8 data, vu8 mask);
+
+-static vu32 readRF(IOADDRESS io_base, vu8 index);
+-static void writeRF(IOADDRESS io_base, vu8 index, vu32 data);
++static vu32 readRF(unsigned long io_base, vu8 index);
++static void writeRF(unsigned long io_base, vu8 index, vu32 data);
+
+-static vu32 risc_readmem(IOADDRESS io_base, vu32 addr, vu8 read_type);
+-static void risc_writemem(IOADDRESS io_base, vu32 addr, vu32 data, vu8 write_type);
++static vu32 risc_readmem(unsigned long io_base, vu32 addr, vu8 read_type);
++static void risc_writemem(unsigned long io_base, vu32 addr, vu32 data, vu8 write_type);
+
+ #if 0
+-static void risc_step(IOADDRESS io_base, vu32 count);
++static void risc_step(unsigned long io_base, vu32 count);
+ #endif
+-static void risc_forcestep(IOADDRESS io_base, vu32 instruction);
+-static void risc_continue(IOADDRESS io_base);
++static void risc_forcestep(unsigned long io_base, vu32 instruction);
++static void risc_continue(unsigned long io_base);
+
+
+
+@@ -113,7 +113,7 @@ void
+ v1k_start(ScrnInfoPtr pScreenInfo, vu32 pc)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS io_base=pRendition->board.io_base;
++ unsigned long io_base=pRendition->board.io_base;
+
+ v1k_stop(pScreenInfo);
+ risc_forcestep(io_base, NOP_INSTR);
+@@ -152,7 +152,7 @@ v1k_stop(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+ vu8 debugreg, statusreg;
+- IOADDRESS io_base=pRendition->board.io_base;
++ unsigned long io_base=pRendition->board.io_base;
+ vu16 STATUS = 0x4A; /* v2x00 io register offset */
+ int c;
+
+@@ -207,7 +207,7 @@ v1k_flushicache(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+ vu32 c, p1, p2;
+- IOADDRESS io_base=pRendition->board.io_base;
++ unsigned long io_base=pRendition->board.io_base;
+
+ /* first flush store accumulation buffers so data is all in memory */
+ p1=risc_readmem(io_base, 0, READ_WORD);
+@@ -255,7 +255,7 @@ void
+ v1k_softreset(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS io_base=pRendition->board.io_base;
++ unsigned long io_base=pRendition->board.io_base;
+
+ verite_out8(io_base+DEBUGREG, SOFTRESET|HOLDRISC);
+ verite_out8(io_base+STATEINDEX, STATEINDEX_PC);
+@@ -300,12 +300,12 @@ v1k_getriscprocs(verite_board_desc *boardDesc)
+ */
+
+ /*
+- * static void verite_iopoll(IOADDRESS port, vu32 data, vu32 mask)
++ * static void verite_iopoll(unsigned long port, vu32 data, vu32 mask)
+ *
+ * Loop on IO read until expected data is read or VERITE_MAX_POLLS is reached.
+ */
+ static void
+-verite_iopoll(IOADDRESS port, vu32 data, vu32 mask)
++verite_iopoll(unsigned long port, vu32 data, vu32 mask)
+ {
+ vu32 c;
+
+@@ -320,12 +320,12 @@ verite_iopoll(IOADDRESS port, vu32 data, vu32 mask)
+
+
+ /*
+- * static void verite_iopoll8(IOADDRESS port, vu8 data, vu8 mask)
++ * static void verite_iopoll8(unsigned long port, vu8 data, vu8 mask)
+ *
+ * Loop on IO read until expected data is read or VERITE_MAX_POLLS is reached.
+ */
+ static void
+-verite_iopoll8(IOADDRESS port, vu8 data, vu8 mask)
++verite_iopoll8(unsigned long port, vu8 data, vu8 mask)
+ {
+ vu32 c;
+
+@@ -340,12 +340,12 @@ verite_iopoll8(IOADDRESS port, vu8 data, vu8 mask)
+
+
+ /*
+- * static vu32 readRF(IOADDRESS io_base, vu8 index)
++ * static vu32 readRF(unsigned long io_base, vu8 index)
+ *
+ * Reads data from register file.
+ */
+ static vu32
+-readRF(IOADDRESS io_base, vu8 index)
++readRF(unsigned long io_base, vu8 index)
+ {
+ vu32 data, instr;
+ vu8 debug, stateindex;
+@@ -378,12 +378,12 @@ readRF(IOADDRESS io_base, vu8 index)
+
+
+ /*
+- * static void writeRF(IOADDRESS io_base, vu8 index, vu32 data)
++ * static void writeRF(unsigned long io_base, vu8 index, vu32 data)
+ *
+ * Set RF register, being careful on how to set regs below 64.
+ */
+ static void
+-writeRF(IOADDRESS io_base, vu8 index, vu32 data)
++writeRF(unsigned long io_base, vu8 index, vu32 data)
+ {
+ vu8 special=0;
+
+@@ -417,12 +417,12 @@ writeRF(IOADDRESS io_base, vu8 index, vu32 data)
+
+
+ /*
+- * static vu32 risc_readmem(IOADDRESS io_base, vu32 addr, vu8 read_type)
++ * static vu32 risc_readmem(unsigned long io_base, vu32 addr, vu8 read_type)
+ *
+ * NOTE: Assumes RISC is in hold mode.
+ */
+ static vu32
+-risc_readmem(IOADDRESS io_base, vu32 addr, vu8 read_type)
++risc_readmem(unsigned long io_base, vu32 addr, vu8 read_type)
+ {
+ vu32 data;
+
+@@ -445,12 +445,12 @@ risc_readmem(IOADDRESS io_base, vu32 addr, vu8 read_type)
+
+
+ /*
+- * static vu32 risc_writemem(IOADDRESS io_base, vu32 addr, vu32 data, vu8 write_type)
++ * static vu32 risc_writemem(unsigned long io_base, vu32 addr, vu32 data, vu8 write_type)
+ *
+ * NOTE: Assumes RISC is in hold mode.
+ */
+ static void
+-risc_writemem(IOADDRESS io_base, vu32 addr, vu32 data, vu8 write_type)
++risc_writemem(unsigned long io_base, vu32 addr, vu32 data, vu8 write_type)
+ {
+ writeRF(io_base, RISC_RA, addr); /* point to memory */
+ writeRF(io_base, RISC_FP, data); /* set data */
+@@ -466,12 +466,12 @@ risc_writemem(IOADDRESS io_base, vu32 addr, vu32 data, vu8 write_type)
+
+ #if 0
+ /*
+- * static void risc_step(IOADDRESS io_base, vu32 count)
++ * static void risc_step(unsigned long io_base, vu32 count)
+ *
+ * Single step the RISC. NOTE: Do not force instruction into RISCIR!
+ */
+ static void
+-risc_step(IOADDRESS io_base, vu32 count)
++risc_step(unsigned long io_base, vu32 count)
+ {
+ vu32 c, d;
+ vu8 debugreg;
+@@ -494,12 +494,12 @@ risc_step(IOADDRESS io_base, vu32 count)
+
+
+ /*
+- * static void risc_forcestep(IOADDRESS io_base, vu32 instruction)
++ * static void risc_forcestep(unsigned long io_base, vu32 instruction)
+ *
+ * Single step RISC; force instruction; assumes RISC held.
+ */
+ static void
+-risc_forcestep(IOADDRESS io_base, vu32 instruction)
++risc_forcestep(unsigned long io_base, vu32 instruction)
+ {
+ vu32 c;
+ vu8 debugreg, stateindex;
+@@ -525,12 +525,12 @@ risc_forcestep(IOADDRESS io_base, vu32 instruction)
+
+
+ /*
+- * static void risc_continue(IOADDRESS io_base)
++ * static void risc_continue(unsigned long io_base)
+ *
+ * Turn off hold bit.
+ */
+ static void
+-risc_continue(IOADDRESS io_base)
++risc_continue(unsigned long io_base)
+ {
+ vu8 debugreg;
+
+diff --git a/src/vboard.c b/src/vboard.c
+index 49499e2..622715f 100644
+--- a/src/vboard.c
++++ b/src/vboard.c
+@@ -38,7 +38,7 @@ verite_initboard(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+
+- IOADDRESS iob=pRendition->board.io_base;
++ unsigned long iob=pRendition->board.io_base;
+ vu8 *vmb;
+ vu32 offset;
+ vu8 memendian;
+@@ -207,7 +207,7 @@ void
+ verite_check_csucode(ScrnInfoPtr pScreenInfo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base;
++ unsigned long iob=pRendition->board.io_base;
+ vu8 *vmb;
+ vu32 offset;
+ int c;
+diff --git a/src/vgafont-std.data b/src/vgafont-std.data
+index db63ea8..c47983f 100644
+--- a/src/vgafont-std.data
++++ b/src/vgafont-std.data
+@@ -1,4 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vgafont-std.data,v 1.3 1999/10/13 04:21:22 dawes Exp $ */
+ #ifndef __VGAFONT_STD__
+ #define __VGAFONT_STD__
+
+diff --git a/src/vgafont-vrx.data b/src/vgafont-vrx.data
+index ad34582..23b5908 100644
+--- a/src/vgafont-vrx.data
++++ b/src/vgafont-vrx.data
+@@ -1,4 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vgafont-vrx.data,v 1.3 1999/10/13 04:21:23 dawes Exp $ */
+ #ifndef __VGAFONT_VRX__
+ #define __VGAFONT_VRX__
+
+diff --git a/src/vgapalette.data b/src/vgapalette.data
+index 5267608..106028d 100644
+--- a/src/vgapalette.data
++++ b/src/vgapalette.data
+@@ -1,4 +1,3 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vgapalette.data,v 1.3 1999/10/13 04:21:23 dawes Exp $ */
+ #ifndef __VGAPALETTE__
+ #define __VGAPALETTE__
+
+diff --git a/src/vloaduc.c b/src/vloaduc.c
+index 67bf901..5c6aab0 100644
+--- a/src/vloaduc.c
++++ b/src/vloaduc.c
+@@ -103,7 +103,7 @@ verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
+ sz=SW16(ehdr.e_phentsize);
+ num=SW16(ehdr.e_phnum);
+ if (0!=sz && 0!=num) {
+- orig_pphdr=pphdr=(Elf32_Phdr *)xalloc(sz*num);
++ orig_pphdr=pphdr=(Elf32_Phdr *)malloc(sz*num);
+ if (!pphdr) {
+ ErrorF("RENDITION: Cannot allocate global memory (1)\n");
+ close(fd);
+@@ -125,7 +125,7 @@ verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
+ sz=SW16(ehdr.e_shentsize);
+ num=SW16(ehdr.e_shnum);
+ if (0!=sz && 0!=num) {
+- orig_pshdr=pshdr=(Elf32_Shdr *)xalloc(sz*num);
++ orig_pshdr=pshdr=(Elf32_Shdr *)malloc(sz*num);
+ if (!pshdr) {
+ ErrorF("RENDITION: Cannot allocate global memory (2)\n");
+ close(fd);
+@@ -148,7 +148,7 @@ verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
+ loadSegment2board(pScreenInfo, fd, pphdr);
+ pphdr=(Elf32_Phdr *)(((char *)pphdr)+sz);
+ } while (--num);
+- xfree(orig_pphdr);
++ free(orig_pphdr);
+ }
+ else {
+ do {
+@@ -158,7 +158,7 @@ verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
+ loadSection2board(pScreenInfo, fd, pshdr);
+ pshdr=(Elf32_Shdr *)(((char *)pshdr)+sz);
+ } while (--num) ;
+- xfree(orig_pshdr);
++ free(orig_pshdr);
+ }
+ close(fd);
+
+@@ -195,7 +195,7 @@ loadSegment2board(ScrnInfoPtr pScreenInfo, int fd, Elf32_Phdr *phdr)
+ return;
+ }
+
+- data=(vu8 *)xalloc(size);
++ data=(vu8 *)malloc(size);
+ if (NULL == data){
+ ErrorF("RENDITION: GlobalAllocPtr couldn't allocate %lx bytes",
+ (unsigned long)size);
+@@ -210,7 +210,7 @@ loadSegment2board(ScrnInfoPtr pScreenInfo, int fd, Elf32_Phdr *phdr)
+
+ mmve(pScreenInfo, size, data, physAddr);
+
+- xfree(data);
++ free(data);
+ }
+
+
+diff --git a/src/vmodes.c b/src/vmodes.c
+index c0bd0df..f2dae0b 100644
+--- a/src/vmodes.c
++++ b/src/vmodes.c
+@@ -20,6 +20,7 @@
+ #include "v1kregs.h"
+ #include "v2kregs.h"
+
++#include <unistd.h>
+
+ #undef DEBUG
+
+@@ -201,7 +202,7 @@ struct V1000ClocksStr {
+ * local function prototypes
+ */
+
+-static void set_PLL(IOADDRESS iob, vu32 value);
++static void set_PLL(unsigned long iob, vu32 value);
+ static double V1000CalcClock(double target, int *M, int *N, int *P);
+ static double V2200CalcClock(double target, int *m, int *n, int *p);
+
+@@ -509,13 +510,13 @@ verite_getstride(ScrnInfoPtr pScreenInfo, int *width,
+ */
+
+ /*
+- * void set_PLL(IOADDRESS iob, vu32 value)
++ * void set_PLL(unsigned long iob, vu32 value)
+ *
+ * Set PLL clock to desired frequency for the V1000.
+ */
+
+ void
+-set_PLL(IOADDRESS iob, vu32 value)
++set_PLL(unsigned long iob, vu32 value)
+ {
+ vu32 ulD;
+ int b;
+diff --git a/src/vos.h b/src/vos.h
+index 7b55f77..999c870 100644
+--- a/src/vos.h
++++ b/src/vos.h
+@@ -23,18 +23,18 @@
+ /*
+ * function prototypes
+ */
+-#define /*void*/ verite_out8(/*IOADDRESS*/ port, /*vu8*/ data) \
++#define /*void*/ verite_out8(/*unsigned long*/ port, /*vu8*/ data) \
+ outb(port, data)
+
+-#define /*void*/ verite_out16(/*IOADDRESS*/ port, /*vu16*/ data) \
++#define /*void*/ verite_out16(/*unsigned long*/ port, /*vu16*/ data) \
+ outw(port, data)
+
+-#define /*void*/ verite_out32(/*IOADDRESS*/ port, /*vu32*/ data) \
++#define /*void*/ verite_out32(/*unsigned long*/ port, /*vu32*/ data) \
+ outl(port, data)
+
+-#define /*vu8*/ verite_in8(/*IOADDRESS*/ io_base) ((vu8)inb(io_base))
+-#define /*vu16*/ verite_in16(/*IOADDRESS*/ io_base) ((vu16)inw(io_base))
+-#define /*vu32*/ verite_in32(/*IOADDRESS*/ io_base) ((vu32)inl(io_base))
++#define /*vu8*/ verite_in8(/*unsigned long*/ io_base) ((vu8)inb(io_base))
++#define /*vu16*/ verite_in16(/*unsigned long*/ io_base) ((vu16)inw(io_base))
++#define /*vu32*/ verite_in32(/*unsigned long*/ io_base) ((vu32)inl(io_base))
+
+ /* memory accesses */
+ #define verite_read_memory32(base, offset) MMIO_IN32(base, offset)
+diff --git a/src/vramdac.c b/src/vramdac.c
+index 7c8acbd..21c1df7 100644
+--- a/src/vramdac.c
++++ b/src/vramdac.c
+@@ -93,11 +93,11 @@
+ * local function prototypes
+ */
+
+-static void Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data);
+-static void Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data);
++static void Bt485_write_masked(unsigned long port, vu8 reg, vu8 mask, vu8 data);
++static void Bt485_write_cmd3_masked(unsigned long port, vu8 mask, vu8 data);
+ #if 0
+-static vu8 Bt485_read_masked(IOADDRESS port, vu8 reg, vu8 mask);
+-static vu8 Bt485_read_cmd3_masked(IOADDRESS port, vu8 mask);
++static vu8 Bt485_read_masked(unsigned long port, vu8 reg, vu8 mask);
++static vu8 Bt485_read_cmd3_masked(unsigned long port, vu8 mask);
+ #endif
+
+ /*
+@@ -159,7 +159,7 @@ int
+ verite_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
++ unsigned long iob=pRendition->board.io_base+RAMDACBASEADDR;
+ vu8 cmd0,cmd1,cmd2;
+ vu8 cmd3_data=0;
+
+@@ -271,7 +271,7 @@ verite_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
+ BT485_3_COLOR_CURSOR, BT485_X_WINDOW_CURSOR };
+ static vu8 csizes[]={ BT485_32_BY_32_CURSOR, BT485_64_BY_64_CURSOR };
+
+- IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
++ unsigned long iob=pRendition->board.io_base+RAMDACBASEADDR;
+
+ #ifdef DEBUG
+ ErrorF ("Rendition: Debug verite_enablecursor called type=0x%x\n",type);
+@@ -304,7 +304,7 @@ void
+ verite_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
++ unsigned long iob=pRendition->board.io_base+RAMDACBASEADDR;
+
+ x+=Cursor_size-xo;
+ y+=Cursor_size-yo;
+@@ -327,7 +327,7 @@ void
+ verite_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 fg, vu32 bg)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
++ unsigned long iob=pRendition->board.io_base+RAMDACBASEADDR;
+
+ #ifdef DEBUG
+ ErrorF ("Rendition: Debug verite_setcursorcolor called FG=0x%x BG=0x%x\n",
+@@ -374,7 +374,7 @@ verite_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
+ int c, bytes, row;
+ vu8 *src = cursorimage;
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base+RAMDACBASEADDR;
++ unsigned long iob=pRendition->board.io_base+RAMDACBASEADDR;
+ vu8 tmp;
+ vu8 memend; /* Added for byte-swap fix */
+
+@@ -454,7 +454,7 @@ verite_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual)
+ {
+ renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
+- IOADDRESS iob=pRendition->board.io_base;
++ unsigned long iob=pRendition->board.io_base;
+ vu32 crtc_status;
+ int i, index;
+
+@@ -485,12 +485,12 @@ verite_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
+ */
+
+ /*
+- * static void Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data)
++ * static void Bt485_write_masked(unsigned long port, vu8 reg, vu8 mask, vu8 data)
+ *
+ *
+ */
+ static void
+-Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data)
++Bt485_write_masked(unsigned long port, vu8 reg, vu8 mask, vu8 data)
+ {
+ vu8 tmp;
+
+@@ -501,12 +501,12 @@ Bt485_write_masked(IOADDRESS port, vu8 reg, vu8 mask, vu8 data)
+
+
+ /*
+- * static void Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data)
++ * static void Bt485_write_cmd3_masked(unsigned long port, vu8 mask, vu8 data)
+ *
+ *
+ */
+ static void
+-Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data)
++Bt485_write_cmd3_masked(unsigned long port, vu8 mask, vu8 data)
+ {
+ /*
+ * Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x80);
+@@ -522,24 +522,24 @@ Bt485_write_cmd3_masked(IOADDRESS port, vu8 mask, vu8 data)
+
+ #if 0
+ /*
+- * static vu8 Bt485_read_masked(IOADDRESS port, vu8 reg, vu8 mask)
++ * static vu8 Bt485_read_masked(unsigned long port, vu8 reg, vu8 mask)
+ *
+ *
+ */
+ static vu8
+-Bt485_read_masked(IOADDRESS port, vu8 reg, vu8 mask)
++Bt485_read_masked(unsigned long port, vu8 reg, vu8 mask)
+ {
+ return verite_in8(port+reg)&mask;
+ }
+
+
+ /*
+- * static vu8 Bt485_read_cmd3_masked(IOADDRESS port, vu8 mask)
++ * static vu8 Bt485_read_cmd3_masked(unsigned long port, vu8 mask)
+ *
+ *
+ */
+ static vu8
+-Bt485_read_cmd3_masked(IOADDRESS port, vu8 mask)
++Bt485_read_cmd3_masked(unsigned long port, vu8 mask)
+ {
+ vu8 value;
+
+diff --git a/src/vtypes.h b/src/vtypes.h
+index 257870b..e4ad468 100644
+--- a/src/vtypes.h
++++ b/src/vtypes.h
+@@ -123,7 +123,7 @@ struct verite_board_t {
+ vu16 chip;
+
+ /* */
+- IOADDRESS io_base, vgaio_base;
++ unsigned long io_base, vgaio_base;
+ vu32 mmio_base;
+ vu32 vmmio_base;
+ vu32 mem_size;
diff --git a/staging/xf86-video-s3/LICENSE b/staging/xf86-video-s3/LICENSE
new file mode 100644
index 000000000..a4c8d5dd4
--- /dev/null
+++ b/staging/xf86-video-s3/LICENSE
@@ -0,0 +1,25 @@
+This package was downloaded from
+http://xorg.freedesktop.org/releases/individual/driver/
+
+ Copyright 2001 Ani Joshi <ajoshi@unixbox.com>
+
+ XFree86 4.x driver for S3 chipsets
+
+
+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 name of Ani Joshi not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission. Ani Joshi makes no representations
+about the suitability of this software for any purpose. It is provided
+"as-is" without express or implied warranty.
+
+ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL ANI JOSHI 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.
diff --git a/staging/xf86-video-s3/PKGBUILD b/staging/xf86-video-s3/PKGBUILD
new file mode 100644
index 000000000..1bc6e2bd4
--- /dev/null
+++ b/staging/xf86-video-s3/PKGBUILD
@@ -0,0 +1,35 @@
+# $Id: PKGBUILD 149870 2012-02-11 11:10:56Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-s3
+pkgver=0.6.3
+pkgrel=7
+pkgdesc="X.org S3 video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ git-fixes.patch)
+md5sums=('5eb06d88533fb327d067928faeb20860'
+ '77a455ce7e254c73b1cbd408c7f4ecf4')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i "${srcdir}/git-fixes.patch"
+ autoreconf -fi
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+}
diff --git a/staging/xf86-video-s3/git-fixes.patch b/staging/xf86-video-s3/git-fixes.patch
new file mode 100644
index 000000000..712b3c9c0
--- /dev/null
+++ b/staging/xf86-video-s3/git-fixes.patch
@@ -0,0 +1,458 @@
+diff --git a/COPYING b/COPYING
+index 7f33cbf..458ab5f 100644
+--- a/COPYING
++++ b/COPYING
+@@ -1,12 +1,70 @@
+-This is a stub file. This package has not yet had its complete licensing
+-information compiled. Please see the individual source files for details on
+-your rights to use and modify this software.
++ Copyright 2001 Ani Joshi <ajoshi@unixbox.com>
+
+-Please submit updated COPYING files to the Xorg bugzilla:
++ XFree86 4.x driver for S3 chipsets
+
+-https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
+
+-All licensing questions regarding this software should be directed at the
+-Xorg mailing list:
++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 name of Ani Joshi not be used in advertising or
++publicity pertaining to distribution of the software without specific,
++written prior permission. Ani Joshi makes no representations
++about the suitability of this software for any purpose. It is provided
++"as-is" without express or implied warranty.
++
++ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
++INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
++EVENT SHALL ANI JOSHI 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.
++Copyright 2007 George Sapountzis
++
++Permission is hereby granted, free of charge, to any person obtaining a
++copy of this software and associated documentation files (the "Software"),
++to deal in the Software without restriction, including without limitation
++the rights to use, copy, modify, merge, publish, distribute, sublicense,
++and/or sell copies of the Software, and to permit persons to whom the
++Software is furnished to do so, subject to the following conditions:
++
++The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++SOFTWARE.
++
++Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
++
++Permission is hereby granted, free of charge, to any person obtaining a copy of
++this software and associated documentation files (the "Software"), to deal in
++the Software without restriction, including without limitation the rights to
++use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
++of the Software, and to permit persons to whom the Software is furnished to do
++so, subject to the following conditions:
++
++The above copyright notice and this permission notice shall be included in all
++copies or substantial portions of the Software.
++
++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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 CONNECTION
++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++Except as contained in this notice, the name of the XFree86 Project 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 XFree86 Project.
++
++
++Copyright 1995-1997 The XFree86 Project, Inc.
++Copyright (c) 1999,2000 The XFree86 Project Inc.
+
+-http://lists.freedesktop.org/mailman/listinfo/xorg
+diff --git a/ChangeLog b/ChangeLog
+deleted file mode 100644
+index ad0b227..0000000
+--- a/ChangeLog
++++ /dev/null
+@@ -1,133 +0,0 @@
+-2009-06-25 Evgeny M. zubok <evgeny.zubok@tochka.ru>
+-
+- * src/s3_driver.c:
+- Revert the old behaviour when the BIOS settings are used for
+- intialization of DRAM/VRAM timings, i. e. we don't touch the
+- timings during initialization phase until any memory option (like
+- slow_edodram) is specified.
+-
+- Add manual page.
+-
+-2009-05-25 Evgeny M. Zubok <evgeny.zubok@tochka.ru>
+-
+- * src/s3_driver.c:
+- * src/s3_video.c:
+-
+- Enable Xv extension for Trio64V+ (thanks to Egor Ivanov for
+- testing on real hardware) and Trio64UV+ (Tested only on Trio64V2 by
+- overriding Chipset with "Trio64UV+" but not on real hardware).
+-
+- S3 Trio64V+ now using NewMMIO. Trio64V+ chips have the same ChipId
+- as Trio32/64 but only with chip revision greater or eq 0x40. So if
+- you have problems with NewMMIO, you may override ChipRev in "Device"
+- section of your xorg.conf: "ChipRev" 0x00. Note: disabling the NewMMIO
+- also disables overlay video (Xv) because it isn't implemented for
+- Old MMIO yet.
+-
+-2009-05-04 Evgeny M. Zubok <evgeny.zubok@tochka.ru>
+-
+- * src/s3_driver.c:
+- * src/s3_shadow.c:
+-
+- Add shadowFB option. It can be used to speedup drawing when
+- hardware acceleration is undesirable or unavailable (for colour depth
+- 24 with 24 bpp framebuffer, for example). shadowFB is disabled by
+- default. Enabling shadowFB option disables HW acceleration. Thanks
+- to Egor Ivanov for initial porting of shadowFB from s3virge.
+-
+- Interlace mode support.
+-
+- Close bug #14999.
+-
+-2008-07-06 Evgeny M. Zubok <evgeny.zubok@tochka.ru>
+-
+- * src/s3_video.c:
+-
+- Streams Processor initialization.
+-
+- XVideo support for 16, 24 and 32 bpp (only for TRIO64V2).
+-
+- * src/s3_driver.c:
+-
+- Add XVideo option (enabled by default).
+-
+- Replace "swcursor" by "hwcursor" option (HW cursor
+- not implemented yet for all chipsets).
+-
+- Close bug #5527: 24-bit colour depth support (24bpp and
+- 32bpp framebuffer) for TRIOs. Acceleration doesn't work
+- with packed colour mode (24 bpp FB) but works with 32bpp
+- framebuffer mode (hardware limitation? -- need data).
+-
+- Fix system hang-up when switching between console and X session.
+-
+- Some minor changes of driver messages.
+-
+-2008-02-23 Evgeny M. Zubok <evgeny.zubok@tochka.ru>
+-
+- * src/s3_driver.c: Add DPMS support for S3 Trio64V2 and possibly
+- others (need testing): S3 Trio64UV+. S3 Aurora64V+ and S3 Trio32/64
+- * src/s3_Trio64DAC: Change clocks for S3 Trio64V2 to make
+- the 1024x768@16bpp mode work.
+- Thanks to Richard Driscoll for these patches.
+-
+-2006-04-07 Adam Jackson <ajax@freedesktop.org>
+-
+- * configure.ac:
+- * src/s3.h:
+- Bump to 0.4.1 for Xv changes.
+-
+-2006-04-07 Aaron Plattner <aplattner@nvidia.com>
+-
+- * src/s3_video.c: (S3PutImage):
+- Add a DrawablePtr argument to the XV functions to pave the way for
+- redirected video.
+-
+-2006-04-07 Adam Jackson <ajax@freedesktop.org>
+-
+- * configure.ac:
+- * src/s3.h:
+- * src/s3_IBMRGB.c:
+- * src/s3_Ti.c:
+- * src/s3_Trio64DAC.c:
+- * src/s3_bios.c:
+- * src/s3_cursor.c:
+- * src/s3_dga.c:
+- * src/s3_driver.c:
+- * src/s3_video.c:
+- Unlibcwrap. Bump server version requirement. Bump to 0.4.0.
+-
+-2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version for X11R7 release.
+-
+-2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version number for final X11R7 release candidate.
+-
+-2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version number for X11R7 RC3 release.
+-
+-2005-12-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Remove extraneous AC_MSG_RESULT.
+-
+-2005-11-29 Adam Jackson <ajax@freedesktop.org>
+-
+- * configure.ac:
+- Only build dlloader modules by default.
+-
+-2005-11-09 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version number for X11R7 RC2 release.
+-
+-2005-11-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update pkgcheck dependencies to work with separate build roots.
+diff --git a/Makefile.am b/Makefile.am
+index 7052905..4c278ba 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,5 +18,15 @@
+ # 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
++MAINTAINERCLEANFILES = ChangeLog INSTALL
++
++.PHONY: ChangeLog INSTALL
++
++INSTALL:
++ $(INSTALL_CMD)
++
++ChangeLog:
++ $(CHANGELOG_CMD)
++
++dist-hook: ChangeLog INSTALL
+diff --git a/configure.ac b/configure.ac
+index 0eecc87..0ac34f9 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,42 +20,50 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-s3],
+- 0.6.3,
++ [0.6.3],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-s3)
+-
++ [xf86-video-s3])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
+-AM_INIT_AUTOMAKE([dist-bzip2])
+-
++# Initialize Automake
++AM_INIT_AUTOMAKE([foreign dist-bzip2])
+ AM_MAINTAINER_MODE
+
+-# Checks for programs.
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
++m4_ifndef([XORG_MACROS_VERSION],
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
++XORG_DEFAULT_OPTIONS
++
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
++
++# Checks for programs.
++AM_PROG_CC_C_O
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.4 xproto fontsproto $REQUIRED_MODULES])
+-sdkdir=$(pkg-config --variable=sdkdir xorg-server)
+
+ # Checks for libraries.
+ SAVE_CPPFLAGS="$CPPFLAGS"
+@@ -65,28 +73,20 @@ AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+ [#include "xorg-server.h"])
+ CPPFLAGS="$SAVE_CPPFLAGS"
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+ if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+ PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+ XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
+ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=s3
+ AC_SUBST([DRIVER_NAME])
+
+-XORG_MANPAGE_SECTIONS
+-XORG_RELEASE_VERSION
+-
+-XORG_CHECK_LINUXDOC
+-
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index f0eb29b..b3688ce 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,27 +1,24 @@
+ #
+ # 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.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a
++# copy of this software and associated documentation files (the "Software"),
++# to deal in the Software without restriction, including without limitation
++# the rights to use, copy, modify, merge, publish, distribute, sublicense,
++# and/or sell copies of the Software, and to permit persons to whom the
++# Software is furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++# DEALINGS IN THE SOFTWARE.
+ #
+
+ drivermandir = $(DRIVER_MAN_DIR)
+@@ -34,25 +31,11 @@ EXTRA_DIST = @DRIVER_NAME@.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+
+-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) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/src/s3.h b/src/s3.h
+index 49b8a54..0875fc9 100644
+--- a/src/s3.h
++++ b/src/s3.h
+@@ -113,7 +113,6 @@ typedef struct _S3Rec {
+ XAAInfoRecPtr pXAA;
+ xf86CursorInfoPtr pCurs;
+ xf86Int10InfoPtr pInt10;
+- vbeInfoPtr pVBE;
+ XF86VideoAdaptorPtr adaptor;
+ S3PortPrivPtr portPrivate;
+
+diff --git a/src/s3_driver.c b/src/s3_driver.c
+index 29e343d..4519b33 100644
+--- a/src/s3_driver.c
++++ b/src/s3_driver.c
+@@ -309,6 +309,7 @@ static Bool S3PreInit(ScrnInfoPtr pScrn, int flags)
+ S3Ptr pS3;
+ vgaHWPtr hwp;
+ ClockRangePtr clockRanges;
++ vbeInfoPtr pVBE;
+ rgb zeros = {0, 0, 0};
+ Gamma gzeros = {0.0, 0.0, 0.0};
+ int i, vgaCRIndex, vgaCRReg;
+@@ -436,7 +437,8 @@ static Bool S3PreInit(ScrnInfoPtr pScrn, int flags)
+ }
+
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+- pS3->pVBE = VBEInit(pS3->pInt10, pEnt->index);
++ pVBE = VBEInit(pS3->pInt10, pEnt->index);
++ vbeFree(pVBE);
+ }
+
+ if (pS3->shadowFB) {
diff --git a/staging/xf86-video-s3virge/PKGBUILD b/staging/xf86-video-s3virge/PKGBUILD
new file mode 100644
index 000000000..d1af0b5e1
--- /dev/null
+++ b/staging/xf86-video-s3virge/PKGBUILD
@@ -0,0 +1,38 @@
+# $Id: PKGBUILD 149875 2012-02-11 11:17:48Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+# Contributor: Alexander Baldeck <alexander@archlinux.org>
+
+pkgname=xf86-video-s3virge
+pkgver=1.10.4
+pkgrel=7
+pkgdesc="X.org S3 Virge video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('pkgconfig' 'xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+options=(!libtool)
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ copyright.patch
+ s3virge-1.10.4-vga.patch)
+md5sums=('6517bbbf808c700502d51acdc44662f8'
+ 'f91fb259e3632fb9130fcbe69ecd9d6a'
+ '45c7d912734c9f7dfc1f42077827cb8e')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i "${srcdir}/copyright.patch"
+ patch -Np1 -i ${srcdir}/s3virge-1.10.4-vga.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-s3virge/copyright.patch b/staging/xf86-video-s3virge/copyright.patch
new file mode 100644
index 000000000..ba988c6d6
--- /dev/null
+++ b/staging/xf86-video-s3virge/copyright.patch
@@ -0,0 +1,82 @@
+From c26da404906258951341c4c4ace793f2dfdc47f8 Mon Sep 17 00:00:00 2001
+From: Gaetan Nadon <memsize@videotron.ca>
+Date: Sun, 13 Jun 2010 14:26:32 +0000
+Subject: COPYING: update file with Copyright notices from source code.
+
+Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+---
+diff --git a/COPYING b/COPYING
+index 7f33cbf..727ca51 100644
+--- a/COPYING
++++ b/COPYING
+@@ -1,12 +1,60 @@
+-This is a stub file. This package has not yet had its complete licensing
+-information compiled. Please see the individual source files for details on
+-your rights to use and modify this software.
++Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+
+-Please submit updated COPYING files to the Xorg bugzilla:
++Permission is hereby granted, free of charge, to any person obtaining a copy of
++this software and associated documentation files (the "Software"), to deal in
++the Software without restriction, including without limitation the rights to
++use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
++of the Software, and to permit persons to whom the Software is furnished to do
++so, subject to the following conditions:
+
+-https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
++The above copyright notice and this permission notice shall be included in all
++copies or substantial portions of the Software.
+
+-All licensing questions regarding this software should be directed at the
+-Xorg mailing list:
++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 CONNECTION
++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++Except as contained in this notice, the name of the XFree86 Project 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 XFree86 Project.
++
++Written by Jake Richter Copyright (c) 1989, 1990 Panacea Inc., Londonderry,
++NH - All Rights Reserved
++
++This code may be freely incorporated in any program without royalty, as long
++as the copyright notice stays intact.
++
++Additions by Kevin E. Martin (martin@cs.unc.edu)
++
++KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
++INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
++EVENT SHALL KEVIN E. MARTIN 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.
++
++Copyright 2007 George Sapountzis
++
++Permission is hereby granted, free of charge, to any person obtaining a
++copy of this software and associated documentation files (the "Software"),
++to deal in the Software without restriction, including without limitation
++the rights to use, copy, modify, merge, publish, distribute, sublicense,
++and/or sell copies of the Software, and to permit persons to whom the
++Software is furnished to do so, subject to the following conditions:
++
++The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++SOFTWARE.
+
+-http://lists.freedesktop.org/mailman/listinfo/xorg
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/staging/xf86-video-s3virge/s3virge-1.10.4-vga.patch b/staging/xf86-video-s3virge/s3virge-1.10.4-vga.patch
new file mode 100644
index 000000000..3fb1fd6cf
--- /dev/null
+++ b/staging/xf86-video-s3virge/s3virge-1.10.4-vga.patch
@@ -0,0 +1,76 @@
+From 92b4671ca75022a56ad9e85b347f81c12157c98f Mon Sep 17 00:00:00 2001
+From: Adam Jackson <ajax@redhat.com>
+Date: Wed, 16 Nov 2011 19:58:29 +0000
+Subject: Adapt to missing PIOOffset in videoabi 12
+
+Signed-off-by: Adam Jackson <ajax@redhat.com>
+---
+diff --git a/src/s3v_driver.c b/src/s3v_driver.c
+index 2ced9ac..0f754dd 100644
+--- a/src/s3v_driver.c
++++ b/src/s3v_driver.c
+@@ -3516,11 +3516,17 @@ S3VEnableMmio(ScrnInfoPtr pScrn)
+ S3VPtr ps3v;
+ IOADDRESS vgaCRIndex, vgaCRReg;
+ unsigned char val;
+-
++ unsigned int PIOOffset = 0;
++
+ PVERB5(" S3VEnableMmio\n");
+
+ hwp = VGAHWPTR(pScrn);
+ ps3v = S3VPTR(pScrn);
++
++#if ABI_VIDEODRV_VERSION < 12
++ PIOOffset = hwp->PIOOffset;
++#endif
++
+ /*
+ * enable chipset (seen on uninitialized secondary cards)
+ * might not be needed once we use the VGA softbooter
+@@ -3533,17 +3539,17 @@ S3VEnableMmio(ScrnInfoPtr pScrn)
+ * to be set correctly already and MMIO _has_ to be
+ * enabled.
+ */
+- val = inb(hwp->PIOOffset + 0x3C3); /*@@@EE*/
+- outb(hwp->PIOOffset + 0x3C3, val | 0x01);
++ val = inb(PIOOffset + 0x3C3); /*@@@EE*/
++ outb(PIOOffset + 0x3C3, val | 0x01);
+ /*
+ * set CR registers to color mode
+ * in mono mode extended CR registers
+ * are not accessible. (EE 05/04/99)
+ */
+- val = inb(hwp->PIOOffset + VGA_MISC_OUT_R); /*@@@EE*/
+- outb(hwp->PIOOffset + VGA_MISC_OUT_W, val | 0x01);
++ val = inb(PIOOffset + VGA_MISC_OUT_R); /*@@@EE*/
++ outb(PIOOffset + VGA_MISC_OUT_W, val | 0x01);
+ vgaHWGetIOBase(hwp); /* Get VGA I/O base */
+- vgaCRIndex = hwp->PIOOffset + hwp->IOBase + 4;
++ vgaCRIndex = PIOOffset + hwp->IOBase + 4;
+ vgaCRReg = vgaCRIndex + 1;
+ #if 1
+ /*
+@@ -3562,7 +3568,7 @@ S3VEnableMmio(ScrnInfoPtr pScrn)
+ /* Enable new MMIO, if TRIO mmio is already */
+ /* enabled, then it stays enabled. */
+ outb(vgaCRReg, ps3v->EnableMmioCR53 | 0x08);
+- outb(hwp->PIOOffset + VGA_MISC_OUT_W, val);
++ outb(PIOOffset + VGA_MISC_OUT_W, val);
+ if (S3_TRIO_3D_SERIES(ps3v->Chipset)) {
+ outb(vgaCRIndex, 0x40);
+ val = inb(vgaCRReg);
+@@ -3584,7 +3590,10 @@ S3VDisableMmio(ScrnInfoPtr pScrn)
+ hwp = VGAHWPTR(pScrn);
+ ps3v = S3VPTR(pScrn);
+
+- vgaCRIndex = hwp->PIOOffset + hwp->IOBase + 4;
++ vgaCRIndex = hwp->IOBase + 4;
++#if ABI_VIDEODRV_VERSION < 12
++ vgaCRIndex += hwp->PIOOffset;
++#endif
+ vgaCRReg = vgaCRIndex + 1;
+ outb(vgaCRIndex, 0x53);
+ /* Restore register's original state */
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/staging/xf86-video-savage/PKGBUILD b/staging/xf86-video-savage/PKGBUILD
new file mode 100644
index 000000000..2b1628c62
--- /dev/null
+++ b/staging/xf86-video-savage/PKGBUILD
@@ -0,0 +1,31 @@
+# $Id: PKGBUILD 149878 2012-02-11 11:24:30Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-savage
+pkgver=2.3.3
+pkgrel=2
+pkgdesc="X.org savage video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libdrm' 'xf86driproto' 'mesa>=8.0') # 'glproto')
+conflicts=('xorg-server<1.11.99.903')
+options=(!libtool !makeflags)
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha256sums=('d3854d375dbf7d83bf90e30d72837ce60d808119c6fa4bb98088e68e7cc7e7b2')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -d -m755 "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-siliconmotion/PKGBUILD b/staging/xf86-video-siliconmotion/PKGBUILD
new file mode 100644
index 000000000..a4a7a3b68
--- /dev/null
+++ b/staging/xf86-video-siliconmotion/PKGBUILD
@@ -0,0 +1,35 @@
+# $Id: PKGBUILD 149880 2012-02-11 11:30:03Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+# Contributor: Alexander Baldeck <alexander@archlinux.org>
+
+pkgname=xf86-video-siliconmotion
+pkgver=1.7.5
+pkgrel=4
+pkgdesc="X.org siliconmotion video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ smi-1.7.5-vga.patch)
+sha1sums=('946acae0822d51da57abe8b7ed049691bd731589'
+ '50b0e4aa858d7f8eb6f7e826f62fde23f01afe48')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/smi-1.7.5-vga.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-siliconmotion/smi-1.7.5-vga.patch b/staging/xf86-video-siliconmotion/smi-1.7.5-vga.patch
new file mode 100644
index 000000000..ef353f0df
--- /dev/null
+++ b/staging/xf86-video-siliconmotion/smi-1.7.5-vga.patch
@@ -0,0 +1,25 @@
+From 037b839c84ad6dcbe9aade420cf0d3bf06f23119 Mon Sep 17 00:00:00 2001
+From: Adam Jackson <ajax@redhat.com>
+Date: Wed, 16 Nov 2011 20:03:25 +0000
+Subject: Adapt to missing PIOOffset in videoabi 12
+
+Signed-off-by: Adam Jackson <ajax@redhat.com>
+---
+diff --git a/src/smi_driver.c b/src/smi_driver.c
+index 9c10e46..86644c7 100644
+--- a/src/smi_driver.c
++++ b/src/smi_driver.c
+@@ -442,7 +442,11 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags)
+ LEAVE(FALSE);
+
+ hwp = VGAHWPTR(pScrn);
++#if ABI_VIDEODRV_VERSION < 12
+ pSmi->PIOBase = hwp->PIOOffset;
++#else
++ pSmi->PIOBase = 0;
++#endif
+
+ xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit vgaCRIndex=%x, vgaIOBase=%x, "
+ "MMIOBase=%p\n", hwp->IOBase + VGA_CRTC_INDEX_OFFSET,
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/staging/xf86-video-sis/PKGBUILD b/staging/xf86-video-sis/PKGBUILD
new file mode 100644
index 000000000..30b67cd30
--- /dev/null
+++ b/staging/xf86-video-sis/PKGBUILD
@@ -0,0 +1,34 @@
+# $Id: PKGBUILD 149882 2012-02-11 11:34:48Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-sis
+pkgver=0.10.3
+pkgrel=6
+pkgdesc="X.org SiS video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86dgaproto' 'libdrm' 'xf86driproto' 'mesa>=8.0') # 'glproto')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ sis-0.10.3-git.patch)
+sha1sums=('158673747e240b0c33499685a32d46bdaead7cd5'
+ '9078c02e9d10384cafb75d675bade8644726c811')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/sis-0.10.3-git.patch
+ ./configure --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-sis/sis-0.10.3-git.patch b/staging/xf86-video-sis/sis-0.10.3-git.patch
new file mode 100644
index 000000000..d355e15b1
--- /dev/null
+++ b/staging/xf86-video-sis/sis-0.10.3-git.patch
@@ -0,0 +1,1460 @@
+diff --git a/configure.ac b/configure.ac
+index 33c0d65..036a448 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,54 +20,53 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-sis],
+- 0.10.3,
++ [0.10.3],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-sis)
+-
++ [xf86-video-sis])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
++# Initialize Automake
+ AM_INIT_AUTOMAKE([foreign dist-bzip2])
+-
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_DEFAULT_OPTIONS
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+ m4_ifndef([XORG_MACROS_VERSION],
+- [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.3)
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
+ XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+-XORG_PROG_RAWCPP
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-AC_ARG_ENABLE(dri, AC_HELP_STRING([--disable-dri],
++AC_ARG_ENABLE(dri, AS_HELP_STRING([--disable-dri],
+ [Disable DRI support [[default=auto]]]),
+ [DRI="$enableval"],
+ [DRI=auto])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto)
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
+-PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto xf86dgaproto $REQUIRED_MODULES])
++# Obtain compiler/linker options for the driver dependencies
++PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto xf86dgaproto >= 2.1 $REQUIRED_MODULES])
+ PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+ HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
+ HAVE_XEXTPROTO_71="no")
+@@ -76,9 +75,6 @@ sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
+
+ # Checks for libraries.
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+ if test "$DRI" != no; then
+ AC_CHECK_FILE([${sdkdir}/dri.h],
+ [have_dri_h="yes"], [have_dri_h="no"])
+@@ -118,20 +114,19 @@ AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+ CPPFLAGS="$SAVE_CPPFLAGS"
+
+ if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+- PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
++ PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.12.901])
+ XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
+ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+-AC_SUBST([DRI_CFLAGS])
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=sis
+ AC_SUBST([DRIVER_NAME])
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 1b26ac2..9ceb36f 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -31,39 +31,9 @@ EXTRA_DIST = @DRIVER_NAME@.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+-
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
+-
+-MANDEFS = \
+- -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \
+- -D__appmansuffix__=$(APP_MAN_SUFFIX) \
+- -D__filemansuffix__=$(FILE_MAN_SUFFIX) \
+- -D__libmansuffix__=$(LIB_MAN_SUFFIX) \
+- -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \
+- -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \
+- -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \
+- -D__xconfigfile__=xorg.conf \
+- -D__xservername__=Xorg
+-
+-# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
+-# to cpp, because that trick does not work on all ANSI C preprocessors.
+-# Delete line numbers from the cpp output (-P is not portable, I guess).
+-# Allow XCOMM to be preceded by whitespace and provide a means of generating
+-# output lines with trailing backslashes.
+-# Allow XHASH to always be substituted, even in cases where XCOMM isn't.
+-
+-CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \
+- -e '/^\#line *[0-9][0-9]* *.*$$/d' \
+- -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \
+- -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
+- -e '/^[ ]*XHASH/s/XHASH/\#/' \
+- -e '/\@\@$$/s/\@\@$$/\\/'
+-
+ SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+ .man.$(DRIVER_MAN_SUFFIX):
+- $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+
+diff --git a/man/sis.man b/man/sis.man
+index 9ae4a1b..578bb68 100644
+--- a/man/sis.man
++++ b/man/sis.man
+@@ -1,17 +1,5 @@
+-.\" $XFree86$
+-.\" $XdotOrg$
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+-#ifdef __xservername__
+-#define __myservername__ __xservername__
+-#else
+-#define __myservername__ XFree86
+-#endif
+-#ifdef __xconfigfile__
+-#define __myxconfigfile__ __xconfigfile__
+-#else
+-#define __myxconfigfile__ XF86Config
+-#endif
+ .TH SIS __drivermansuffix__ __vendorversion__
+ .SH NAME
+ sis \- SiS and XGI video driver
+@@ -25,7 +13,7 @@ sis \- SiS and XGI video driver
+ .fi
+ .SH DESCRIPTION
+ .B sis
+-is an __myservername__ driver for SiS (Silicon Integrated Systems) and XGI video
++is an __xservername__ driver for SiS (Silicon Integrated Systems) and XGI video
+ chips. The driver is accelerated and provides support for colordepths of 8, 16
+ and 24 bpp. XVideo, Render and other extensions are supported as well.
+ .SH SUPPORTED HARDWARE
+@@ -60,7 +48,7 @@ for SiS315, 55x, 330, 661/741/76x (plus M, FX, MX, GX variants thereof), 340
+ and all XGI chips.
+ .PP
+ .SH CONFIGURATION DETAILS
+-Please refer to __myxconfigfile__(__filemansuffix__) for general configuration
++Please refer to __xconfigfile__(__filemansuffix__) for general configuration
+ details. This section only covers configuration details specific to this
+ driver.
+ .PP
+@@ -428,11 +416,7 @@ The amount is to be specified in megabyte, the default is 8.
+ .SH "KNOWN BUGS"
+ none.
+ .SH "SEE ALSO"
+-#ifdef __xservername__
+ __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
+-#else
+-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+-#endif
+ .PP
+ .B "http://www.winischhofer.eu/linuxsisvga.shtml"
+ for more information and updates
+diff --git a/src/initextx.c b/src/initextx.c
+index 5c00398..1e84d0f 100644
+--- a/src/initextx.c
++++ b/src/initextx.c
+@@ -238,10 +238,10 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo
+ continue;
+ }
+
+- if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
++ if(!(new = malloc(sizeof(DisplayModeRec)))) return first;
+ memset(new, 0, sizeof(DisplayModeRec));
+- if(!(new->name = xalloc(10))) {
+- xfree(new);
++ if(!(new->name = malloc(10))) {
++ free(new);
+ return first;
+ }
+ if(!first) first = new;
+@@ -385,11 +385,11 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo
+ }
+ }
+
+- if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
++ if(!(new = malloc(sizeof(DisplayModeRec)))) return first;
+
+ memset(new, 0, sizeof(DisplayModeRec));
+- if(!(new->name = xalloc(12))) {
+- xfree(new);
++ if(!(new->name = malloc(12))) {
++ free(new);
+ return first;
+ }
+ if(!first) first = new;
+@@ -470,11 +470,11 @@ SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfo
+
+ if(pSiS->SiS_Pr->CP_DataValid[i]) {
+
+- if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
++ if(!(new = malloc(sizeof(DisplayModeRec)))) return first;
+
+ memset(new, 0, sizeof(DisplayModeRec));
+- if(!(new->name = xalloc(10))) {
+- xfree(new);
++ if(!(new->name = malloc(10))) {
++ free(new);
+ return first;
+ }
+ if(!first) first = new;
+diff --git a/src/osdef.h b/src/osdef.h
+index cd6b907..5776910 100644
+--- a/src/osdef.h
++++ b/src/osdef.h
+@@ -110,12 +110,12 @@
+ #warning sisfb will not work!
+ #endif
+
+-#define OutPortByte(p,v) outb((u8)(v),(IOADDRESS)(p))
+-#define OutPortWord(p,v) outw((u16)(v),(IOADDRESS)(p))
+-#define OutPortLong(p,v) outl((u32)(v),(IOADDRESS)(p))
+-#define InPortByte(p) inb((IOADDRESS)(p))
+-#define InPortWord(p) inw((IOADDRESS)(p))
+-#define InPortLong(p) inl((IOADDRESS)(p))
++#define OutPortByte(p,v) outb((u8)(v),(unsigned long)(p))
++#define OutPortWord(p,v) outw((u16)(v),(unsigned long)(p))
++#define OutPortLong(p,v) outl((u32)(v),(unsigned long)(p))
++#define InPortByte(p) inb((unsigned long)(p))
++#define InPortWord(p) inw((unsigned long)(p))
++#define InPortLong(p) inl((unsigned long)(p))
+ #define SiS_SetMemory(MemoryAddress,MemorySize,value) memset_io(MemoryAddress, value, MemorySize)
+
+ #endif /* LINUX_KERNEL */
+@@ -129,12 +129,12 @@
+ #define SIS300
+ #define SIS315H
+
+-#define OutPortByte(p,v) outSISREG((IOADDRESS)(p),(CARD8)(v))
+-#define OutPortWord(p,v) outSISREGW((IOADDRESS)(p),(CARD16)(v))
+-#define OutPortLong(p,v) outSISREGL((IOADDRESS)(p),(CARD32)(v))
+-#define InPortByte(p) inSISREG((IOADDRESS)(p))
+-#define InPortWord(p) inSISREGW((IOADDRESS)(p))
+-#define InPortLong(p) inSISREGL((IOADDRESS)(p))
++#define OutPortByte(p,v) outSISREG((unsigned long)(p),(CARD8)(v))
++#define OutPortWord(p,v) outSISREGW((unsigned long)(p),(CARD16)(v))
++#define OutPortLong(p,v) outSISREGL((unsigned long)(p),(CARD32)(v))
++#define InPortByte(p) inSISREG((unsigned long)(p))
++#define InPortWord(p) inSISREGW((unsigned long)(p))
++#define InPortLong(p) inSISREGL((unsigned long)(p))
+ #define SiS_SetMemory(MemoryAddress,MemorySize,value) memset(MemoryAddress, value, MemorySize)
+
+ #endif /* XF86 */
+diff --git a/src/sis.h b/src/sis.h
+index 400b83f..9af31a5 100644
+--- a/src/sis.h
++++ b/src/sis.h
+@@ -86,6 +86,14 @@
+ #include "xf86cmap.h"
+ #include "vbe.h"
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++#define _swapl(x, n) swapl(x,n)
++#define _swaps(x, n) swaps(x,n)
++#else
++#define _swapl(x, n) swapl(x)
++#define _swaps(x, n) swaps(x)
++#endif
++
+ #define SIS_HaveDriverFuncs 0
+
+ #undef SISISXORG6899900
+@@ -251,7 +259,6 @@
+ #endif
+
+ /* Need that for SiSCtrl and Pseudo-Xinerama */
+-#define NEED_REPLIES /* ? */
+ #define EXTENSION_PROC_ARGS void *
+ #include "extnsionst.h" /* required */
+ #include <X11/extensions/panoramiXproto.h> /* required */
+@@ -971,7 +978,7 @@ typedef struct {
+ void *RealFbBase; /* Real VRAM virtual linear address (for DHM and SiS76x UMA skipping) */
+ CARD32 IOAddress; /* MMIO physical address */
+ void *IOBase; /* MMIO linear address */
+- IOADDRESS IODBase; /* Base of PIO memory area */
++ unsigned long IODBase; /* Base of PIO memory area */
+ #ifdef __alpha__
+ void *IOBaseDense; /* MMIO for Alpha platform */
+ #endif
+@@ -1348,7 +1355,7 @@ typedef struct {
+ Bool skipswitchcheck;
+ unsigned int VBFlagsInit;
+ DisplayModePtr currentModeLast;
+- IOADDRESS MyPIOOffset;
++ unsigned long MyPIOOffset;
+ Bool OverruleRanges;
+ Bool BenchMemCpy;
+ Bool NeedCopyFastVidCpy;
+diff --git a/src/sis6326_video.c b/src/sis6326_video.c
+index c6b18e2..66352b7 100644
+--- a/src/sis6326_video.c
++++ b/src/sis6326_video.c
+@@ -170,7 +170,7 @@ void SIS6326InitVideo(ScreenPtr pScreen)
+ adaptors = &newAdaptor;
+ } else {
+ /* need to free this someplace */
+- newAdaptors = xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
++ newAdaptors = malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
+ if(newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(XF86VideoAdaptorPtr));
+@@ -185,7 +185,7 @@ void SIS6326InitVideo(ScreenPtr pScreen)
+ xf86XVScreenInit(pScreen, adaptors, num_adaptors);
+
+ if(newAdaptors)
+- xfree(newAdaptors);
++ free(newAdaptors);
+ }
+
+ /* client libraries expect an encoding */
+@@ -531,7 +531,7 @@ SIS6326SetupImageVideo(ScreenPtr pScreen)
+ return NULL;
+ #endif
+
+- if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
++ if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
+ sizeof(SISPortPrivRec) +
+ sizeof(DevUnion))))
+ return NULL;
+diff --git a/src/sis_dga.c b/src/sis_dga.c
+index d358645..16b0ee4 100644
+--- a/src/sis_dga.c
++++ b/src/sis_dga.c
+@@ -150,18 +150,18 @@ SISSetupDGAMode(
+
+ if(pMode->HDisplay != otherPitch) {
+
+- newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec));
++ newmodes = realloc(modes, (*num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+
+ } else {
+
+- newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec));
++ newmodes = realloc(modes, (*num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+
+ }
+
+ if(!newmodes) {
+- xfree(modes);
++ free(modes);
+ return NULL;
+ }
+ modes = newmodes;
+diff --git a/src/sis_dri.c b/src/sis_dri.c
+index 3a476a2..97ed951 100644
+--- a/src/sis_dri.c
++++ b/src/sis_dri.c
+@@ -149,19 +149,19 @@ SISInitVisualConfigs(ScreenPtr pScreen)
+ case 32:
+ numConfigs = (useZ16) ? 8 : 16;
+
+- if(!(pConfigs = (__GLXvisualConfig*)xcalloc(sizeof(__GLXvisualConfig),
++ if(!(pConfigs = (__GLXvisualConfig*)calloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+- if(!(pSISConfigs = (SISConfigPrivPtr)xcalloc(sizeof(SISConfigPrivRec),
++ if(!(pSISConfigs = (SISConfigPrivPtr)calloc(sizeof(SISConfigPrivRec),
+ numConfigs))) {
+- xfree(pConfigs);
++ free(pConfigs);
+ return FALSE;
+ }
+- if(!(pSISConfigPtrs = (SISConfigPrivPtr*)xcalloc(sizeof(SISConfigPrivPtr),
++ if(!(pSISConfigPtrs = (SISConfigPrivPtr*)calloc(sizeof(SISConfigPrivPtr),
+ numConfigs))) {
+- xfree(pConfigs);
+- xfree(pSISConfigs);
++ free(pConfigs);
++ free(pSISConfigs);
+ return FALSE;
+ }
+ for(i=0; i<numConfigs; i++) pSISConfigPtrs[i] = &pSISConfigs[i];
+@@ -319,7 +319,7 @@ SISDRIScreenInit(ScreenPtr pScreen)
+ pDRIInfo->busIdString = DRICreatePCIBusID(pSIS->PciInfo);
+ } else {
+ #endif
+- pDRIInfo->busIdString = xalloc(64);
++ pDRIInfo->busIdString = malloc(64);
+ sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
+ pSIS->PciBus, pSIS->PciDevice, pSIS->PciFunc);
+ #ifdef SISHAVECREATEBUSID
+@@ -383,7 +383,7 @@ SISDRIScreenInit(ScreenPtr pScreen)
+ pDRIInfo->SAREASize = SAREA_MAX;
+ #endif
+
+- if(!(pSISDRI = (SISDRIPtr)xcalloc(sizeof(SISDRIRec), 1))) {
++ if(!(pSISDRI = (SISDRIPtr)calloc(sizeof(SISDRIRec), 1))) {
+ DRIDestroyInfoRec(pSIS->pDRIInfo);
+ pSIS->pDRIInfo = 0;
+ return FALSE;
+@@ -401,7 +401,7 @@ SISDRIScreenInit(ScreenPtr pScreen)
+
+ if(!DRIScreenInit(pScreen, pDRIInfo, &pSIS->drmSubFD)) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] DRIScreenInit failed. Disabling the DRI.\n");
+- xfree(pDRIInfo->devPrivate);
++ free(pDRIInfo->devPrivate);
+ pDRIInfo->devPrivate = 0;
+ DRIDestroyInfoRec(pSIS->pDRIInfo);
+ pSIS->pDRIInfo = 0;
+@@ -794,7 +794,7 @@ SISDRICloseScreen(ScreenPtr pScreen)
+
+ if(pSIS->pDRIInfo) {
+ if(pSIS->pDRIInfo->devPrivate) {
+- xfree(pSIS->pDRIInfo->devPrivate);
++ free(pSIS->pDRIInfo->devPrivate);
+ pSIS->pDRIInfo->devPrivate = NULL;
+ }
+ DRIDestroyInfoRec(pSIS->pDRIInfo);
+@@ -802,12 +802,12 @@ SISDRICloseScreen(ScreenPtr pScreen)
+ }
+
+ if(pSIS->pVisualConfigs) {
+- xfree(pSIS->pVisualConfigs);
++ free(pSIS->pVisualConfigs);
+ pSIS->pVisualConfigs = NULL;
+ }
+
+ if(pSIS->pVisualConfigsPriv) {
+- xfree(pSIS->pVisualConfigsPriv);
++ free(pSIS->pVisualConfigsPriv);
+ pSIS->pVisualConfigsPriv = NULL;
+ }
+
+diff --git a/src/sis_driver.c b/src/sis_driver.c
+index d95b5f1..7ac9487 100644
+--- a/src/sis_driver.c
++++ b/src/sis_driver.c
+@@ -74,8 +74,7 @@
+
+ #include "sis_driver.h"
+
+-#define _XF86DGA_SERVER_
+-#include <X11/extensions/xf86dgastr.h>
++#include <X11/extensions/xf86dgaproto.h>
+
+ #include "globals.h"
+
+@@ -91,6 +90,26 @@
+ #include "dri.h"
+ #endif
+
++/*
++ * LookupWindow was removed with video abi 11.
++ */
++#if (GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 4)
++#ifndef DixGetAttrAccess
++#define DixGetAttrAccess (1<<4)
++#endif
++#endif
++
++#if (GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 2)
++static inline int
++dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
++{
++ *pWin = LookupWindow(id, client);
++ if (!*pWin)
++ return BadWindow;
++ return Success;
++}
++#endif
++
+ /* Globals (yes, these ARE really required to be global) */
+
+ #ifdef SISUSEDEVPORT
+@@ -299,9 +318,9 @@ SISFreeRec(ScrnInfoPtr pScrn)
+ pSiSEnt = pSiS->entityPrivate;
+ #endif
+
+- if(pSiS->pstate) xfree(pSiS->pstate);
++ if(pSiS->pstate) free(pSiS->pstate);
+ pSiS->pstate = NULL;
+- if(pSiS->fonts) xfree(pSiS->fonts);
++ if(pSiS->fonts) free(pSiS->fonts);
+ pSiS->fonts = NULL;
+
+ #ifdef SISDUALHEAD
+@@ -312,11 +331,11 @@ SISFreeRec(ScrnInfoPtr pScrn)
+ * and we need the BIOS image and SiS_Private for the first
+ * head.
+ */
+- if(pSiSEnt->BIOS) xfree(pSiSEnt->BIOS);
++ if(pSiSEnt->BIOS) free(pSiSEnt->BIOS);
+ pSiSEnt->BIOS = pSiS->BIOS = NULL;
+- if(pSiSEnt->SiS_Pr) xfree(pSiSEnt->SiS_Pr);
++ if(pSiSEnt->SiS_Pr) free(pSiSEnt->SiS_Pr);
+ pSiSEnt->SiS_Pr = pSiS->SiS_Pr = NULL;
+- if(pSiSEnt->RenderAccelArray) xfree(pSiSEnt->RenderAccelArray);
++ if(pSiSEnt->RenderAccelArray) free(pSiSEnt->RenderAccelArray);
+ pSiSEnt->RenderAccelArray = pSiS->RenderAccelArray = NULL;
+ pSiSEnt->pScrn_1 = NULL;
+ } else {
+@@ -327,21 +346,21 @@ SISFreeRec(ScrnInfoPtr pScrn)
+ }
+ } else {
+ #endif
+- if(pSiS->BIOS) xfree(pSiS->BIOS);
++ if(pSiS->BIOS) free(pSiS->BIOS);
+ pSiS->BIOS = NULL;
+- if(pSiS->SiS_Pr) xfree(pSiS->SiS_Pr);
++ if(pSiS->SiS_Pr) free(pSiS->SiS_Pr);
+ pSiS->SiS_Pr = NULL;
+- if(pSiS->RenderAccelArray) xfree(pSiS->RenderAccelArray);
++ if(pSiS->RenderAccelArray) free(pSiS->RenderAccelArray);
+ pSiS->RenderAccelArray = NULL;
+ #ifdef SISDUALHEAD
+ }
+ #endif
+ #ifdef SISMERGED
+- if(pSiS->CRT2HSync) xfree(pSiS->CRT2HSync);
++ if(pSiS->CRT2HSync) free(pSiS->CRT2HSync);
+ pSiS->CRT2HSync = NULL;
+- if(pSiS->CRT2VRefresh) xfree(pSiS->CRT2VRefresh);
++ if(pSiS->CRT2VRefresh) free(pSiS->CRT2VRefresh);
+ pSiS->CRT2VRefresh = NULL;
+- if(pSiS->MetaModes) xfree(pSiS->MetaModes);
++ if(pSiS->MetaModes) free(pSiS->MetaModes);
+ pSiS->MetaModes = NULL;
+ if(pSiS->CRT2pScrn) {
+ if(pSiS->CRT2pScrn->modes) {
+@@ -353,10 +372,10 @@ SISFreeRec(ScrnInfoPtr pScrn)
+ while(pSiS->CRT2pScrn->monitor->Modes)
+ xf86DeleteMode(&pSiS->CRT2pScrn->monitor->Modes, pSiS->CRT2pScrn->monitor->Modes);
+ }
+- if(pSiS->CRT2pScrn->monitor->DDC) xfree(pSiS->CRT2pScrn->monitor->DDC);
+- xfree(pSiS->CRT2pScrn->monitor);
++ if(pSiS->CRT2pScrn->monitor->DDC) free(pSiS->CRT2pScrn->monitor->DDC);
++ free(pSiS->CRT2pScrn->monitor);
+ }
+- xfree(pSiS->CRT2pScrn);
++ free(pSiS->CRT2pScrn);
+ pSiS->CRT2pScrn = NULL;
+ }
+ if(pSiS->CRT1Modes) {
+@@ -366,8 +385,8 @@ SISFreeRec(ScrnInfoPtr pScrn)
+ do {
+ DisplayModePtr p = pScrn->currentMode->next;
+ if(pScrn->currentMode->Private)
+- xfree(pScrn->currentMode->Private);
+- xfree(pScrn->currentMode);
++ free(pScrn->currentMode->Private);
++ free(pScrn->currentMode);
+ pScrn->currentMode = p;
+ } while(pScrn->currentMode != pScrn->modes);
+ }
+@@ -380,7 +399,7 @@ SISFreeRec(ScrnInfoPtr pScrn)
+ #endif
+ while(pSiS->SISVESAModeList) {
+ sisModeInfoPtr mp = pSiS->SISVESAModeList->next;
+- xfree(pSiS->SISVESAModeList);
++ free(pSiS->SISVESAModeList);
+ pSiS->SISVESAModeList = mp;
+ }
+ if(pSiS->pVbe) vbeFree(pSiS->pVbe);
+@@ -392,7 +411,7 @@ SISFreeRec(ScrnInfoPtr pScrn)
+
+ if(pScrn->driverPrivate == NULL)
+ return;
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -501,7 +520,7 @@ SISProbe(DriverPtr drv, int flags)
+ numDevSections, drv, &usedChipsXGI);
+
+ /* Free it since we don't need that list after this */
+- xfree(devSections);
++ free(devSections);
+
+ numUsed = numUsedSiS + numUsedXGI;
+
+@@ -577,8 +596,8 @@ SISProbe(DriverPtr drv, int flags)
+
+ }
+
+- if(usedChipsSiS) xfree(usedChipsSiS);
+- if(usedChipsXGI) xfree(usedChipsXGI);
++ if(usedChipsSiS) free(usedChipsSiS);
++ if(usedChipsXGI) free(usedChipsXGI);
+
+ return foundScreen;
+ }
+@@ -642,10 +661,10 @@ SISCalculateGammaRamp(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+ if(!(nramp = xf86GetGammaRampSize(pScreen))) return;
+
+ for(i=0; i<3; i++) {
+- ramp[i] = (UShort *)xalloc(nramp * sizeof(UShort));
++ ramp[i] = (UShort *)malloc(nramp * sizeof(UShort));
+ if(!ramp[i]) {
+- if(ramp[0]) { xfree(ramp[0]); ramp[0] = NULL; }
+- if(ramp[1]) { xfree(ramp[1]); ramp[1] = NULL; }
++ if(ramp[0]) { free(ramp[0]); ramp[0] = NULL; }
++ if(ramp[1]) { free(ramp[1]); ramp[1] = NULL; }
+ return;
+ }
+ }
+@@ -705,9 +724,9 @@ SISCalculateGammaRamp(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+
+ xf86ChangeGammaRamp(pScreen, nramp, ramp[0], ramp[1], ramp[2]);
+
+- xfree(ramp[0]);
+- xfree(ramp[1]);
+- xfree(ramp[2]);
++ free(ramp[0]);
++ free(ramp[1]);
++ free(ramp[2]);
+ ramp[0] = ramp[1] = ramp[2] = NULL;
+ }
+ #endif
+@@ -1135,10 +1154,10 @@ SiSCopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest,
+ DisplayModePtr mode;
+ int dx = 0,dy = 0;
+
+- if(!((mode = xalloc(sizeof(DisplayModeRec))))) return dest;
++ if(!((mode = malloc(sizeof(DisplayModeRec))))) return dest;
+ memcpy(mode, i, sizeof(DisplayModeRec));
+- if(!((mode->Private = xalloc(sizeof(SiSMergedDisplayModeRec))))) {
+- xfree(mode);
++ if(!((mode->Private = malloc(sizeof(SiSMergedDisplayModeRec))))) {
++ free(mode);
+ return dest;
+ }
+ ((SiSMergedDisplayModePtr)mode->Private)->CRT1 = i;
+@@ -1223,8 +1242,8 @@ SiSCopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest,
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Skipped \"%s\" (%dx%d), not enough video RAM or beyond hardware specs\n",
+ mode->name, mode->HDisplay, mode->VDisplay);
+- xfree(mode->Private);
+- xfree(mode);
++ free(mode->Private);
++ free(mode);
+
+ return dest;
+ }
+@@ -2131,10 +2150,10 @@ SiSProcXineramaQueryVersion(ClientPtr client)
+ rep.majorVersion = SIS_XINERAMA_MAJOR_VERSION;
+ rep.minorVersion = SIS_XINERAMA_MINOR_VERSION;
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swaps(&rep.majorVersion, n);
+- swaps(&rep.minorVersion, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swaps(&rep.majorVersion, n);
++ _swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xPanoramiXQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+@@ -2147,19 +2166,20 @@ SiSProcXineramaGetState(ClientPtr client)
+ WindowPtr pWin;
+ xPanoramiXGetStateReply rep;
+ register int n;
++ int rc;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+- pWin = LookupWindow(stuff->window, client);
+- if(!pWin) return BadWindow;
++ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
++ if (rc != Success)
++ return rc;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.state = !SiSnoPanoramiXExtension;
+ if(client->swapped) {
+- swaps (&rep.sequenceNumber, n);
+- swapl (&rep.length, n);
+- swaps (&rep.state, n);
++ _swaps (&rep.sequenceNumber, n);
++ _swapl (&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xPanoramiXGetStateReply), (char *)&rep);
+ return client->noClientException;
+@@ -2172,19 +2192,20 @@ SiSProcXineramaGetScreenCount(ClientPtr client)
+ WindowPtr pWin;
+ xPanoramiXGetScreenCountReply rep;
+ register int n;
++ int rc;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+- pWin = LookupWindow(stuff->window, client);
+- if(!pWin) return BadWindow;
++ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
++ if (rc != Success)
++ return rc;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.ScreenCount = SiSXineramaNumScreens;
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swaps(&rep.ScreenCount, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
+ return client->noClientException;
+@@ -2197,10 +2218,12 @@ SiSProcXineramaGetScreenSize(ClientPtr client)
+ WindowPtr pWin;
+ xPanoramiXGetScreenSizeReply rep;
+ register int n;
++ int rc;
+
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+- pWin = LookupWindow (stuff->window, client);
+- if(!pWin) return BadWindow;
++ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
++ if (rc != Success)
++ return rc;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+@@ -2208,10 +2231,10 @@ SiSProcXineramaGetScreenSize(ClientPtr client)
+ rep.width = SiSXineramadataPtr[stuff->screen].width;
+ rep.height = SiSXineramadataPtr[stuff->screen].height;
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swaps(&rep.width, n);
+- swaps(&rep.height, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swapl(&rep.width, n);
++ _swapl(&rep.height, n);
+ }
+ WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
+ return client->noClientException;
+@@ -2230,9 +2253,9 @@ SiSProcXineramaIsActive(ClientPtr client)
+ rep.state = !SiSnoPanoramiXExtension;
+ if(client->swapped) {
+ register int n;
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swapl(&rep.state, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swapl(&rep.state, n);
+ }
+ WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
+ return client->noClientException;
+@@ -2251,9 +2274,9 @@ SiSProcXineramaQueryScreens(ClientPtr client)
+ rep.length = rep.number * sz_XineramaScreenInfo >> 2;
+ if(client->swapped) {
+ register int n;
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swapl(&rep.number, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swapl(&rep.number, n);
+ }
+ WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);
+
+@@ -2268,10 +2291,10 @@ SiSProcXineramaQueryScreens(ClientPtr client)
+ scratch.height = SiSXineramadataPtr[i].height;
+ if(client->swapped) {
+ register int n;
+- swaps(&scratch.x_org, n);
+- swaps(&scratch.y_org, n);
+- swaps(&scratch.width, n);
+- swaps(&scratch.height, n);
++ _swaps(&scratch.x_org, n);
++ _swaps(&scratch.y_org, n);
++ _swaps(&scratch.width, n);
++ _swaps(&scratch.height, n);
+ }
+ WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
+ }
+@@ -2308,7 +2331,7 @@ SiSSProcXineramaQueryVersion (ClientPtr client)
+ {
+ REQUEST(xPanoramiXQueryVersionReq);
+ register int n;
+- swaps(&stuff->length,n);
++ _swaps(&stuff->length,n);
+ REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
+ return SiSProcXineramaQueryVersion(client);
+ }
+@@ -2318,7 +2341,7 @@ SiSSProcXineramaGetState(ClientPtr client)
+ {
+ REQUEST(xPanoramiXGetStateReq);
+ register int n;
+- swaps (&stuff->length, n);
++ _swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+ return SiSProcXineramaGetState(client);
+ }
+@@ -2328,7 +2351,7 @@ SiSSProcXineramaGetScreenCount(ClientPtr client)
+ {
+ REQUEST(xPanoramiXGetScreenCountReq);
+ register int n;
+- swaps (&stuff->length, n);
++ _swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+ return SiSProcXineramaGetScreenCount(client);
+ }
+@@ -2338,7 +2361,7 @@ SiSSProcXineramaGetScreenSize(ClientPtr client)
+ {
+ REQUEST(xPanoramiXGetScreenSizeReq);
+ register int n;
+- swaps (&stuff->length, n);
++ _swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+ return SiSProcXineramaGetScreenSize(client);
+ }
+@@ -2348,7 +2371,7 @@ SiSSProcXineramaIsActive(ClientPtr client)
+ {
+ REQUEST(xXineramaIsActiveReq);
+ register int n;
+- swaps (&stuff->length, n);
++ _swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+ return SiSProcXineramaIsActive(client);
+ }
+@@ -2358,7 +2381,7 @@ SiSSProcXineramaQueryScreens(ClientPtr client)
+ {
+ REQUEST(xXineramaQueryScreensReq);
+ register int n;
+- swaps (&stuff->length, n);
++ _swaps (&stuff->length, n);
+ REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+ return SiSProcXineramaQueryScreens(client);
+ }
+@@ -2389,7 +2412,7 @@ SiSXineramaResetProc(ExtensionEntry* extEntry)
+ {
+ /* Called by CloseDownExtensions() */
+ if(SiSXineramadataPtr) {
+- Xfree(SiSXineramadataPtr);
++ free(SiSXineramadataPtr);
+ SiSXineramadataPtr = NULL;
+ }
+ }
+@@ -2454,7 +2477,7 @@ SiSXineramaExtensionInit(ScrnInfoPtr pScrn)
+ if(!pSiS->XineramaExtEntry) break;
+
+ if(!(SiSXineramadataPtr = (SiSXineramaData *)
+- xcalloc(SiSXineramaNumScreens, sizeof(SiSXineramaData)))) break;
++ calloc(SiSXineramaNumScreens, sizeof(SiSXineramaData)))) break;
+
+ SiSXineramaGeneration = serverGeneration;
+ success = TRUE;
+@@ -2493,10 +2516,10 @@ SiSFreeCRT2Structs(SISPtr pSiS)
+ while(pSiS->CRT2pScrn->monitor->Modes)
+ xf86DeleteMode(&pSiS->CRT2pScrn->monitor->Modes, pSiS->CRT2pScrn->monitor->Modes);
+ }
+- if(pSiS->CRT2pScrn->monitor->DDC) xfree(pSiS->CRT2pScrn->monitor->DDC);
+- xfree(pSiS->CRT2pScrn->monitor);
++ if(pSiS->CRT2pScrn->monitor->DDC) free(pSiS->CRT2pScrn->monitor->DDC);
++ free(pSiS->CRT2pScrn->monitor);
+ }
+- xfree(pSiS->CRT2pScrn);
++ free(pSiS->CRT2pScrn);
+ pSiS->CRT2pScrn = NULL;
+ }
+ }
+@@ -2902,22 +2925,22 @@ SiS_CheckKernelFB(ScrnInfoPtr pScrn)
+ Bool gotit = FALSE;
+
+ if(!ioctl(fd, SISFB_GET_INFO_SIZE, &sisfbinfosize)) {
+- if((mysisfbinfo = xalloc(sisfbinfosize))) {
++ if((mysisfbinfo = malloc(sisfbinfosize))) {
+ if(!ioctl(fd, (SISFB_GET_INFO | (sisfbinfosize << 16)), mysisfbinfo)) {
+ gotit = TRUE;
+ } else {
+- xfree(mysisfbinfo);
++ free(mysisfbinfo);
+ mysisfbinfo = NULL;
+ }
+ }
+ } else {
+- if((mysisfbinfo = xalloc(sizeof(*mysisfbinfo) + 16))) {
++ if((mysisfbinfo = malloc(sizeof(*mysisfbinfo) + 16))) {
+ if(!ioctl(fd, SISFB_GET_INFO_OLD, mysisfbinfo)) {
+ gotit = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Possibly old version of sisfb detected. Please update.\n");
+ } else {
+- xfree(mysisfbinfo);
++ free(mysisfbinfo);
+ mysisfbinfo = NULL;
+ }
+ }
+@@ -3056,7 +3079,7 @@ SiS_CheckKernelFB(ScrnInfoPtr pScrn)
+ }
+ }
+ }
+- xfree(mysisfbinfo);
++ free(mysisfbinfo);
+ mysisfbinfo = NULL;
+ }
+ close (fd);
+@@ -3216,7 +3239,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ pSiS->pInt = NULL;
+
+ /* Save PCI Domain Base */
+-#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0)
++#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) || GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 12
+ pSiS->IODBase = 0;
+ #else
+ pSiS->IODBase = pScrn->domainIOBase;
+@@ -4078,7 +4101,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ }
+ #endif
+ if(!pSiS->BIOS) {
+- if(!(pSiS->BIOS = xcalloc(1, BIOS_SIZE))) {
++ if(!(pSiS->BIOS = calloc(1, BIOS_SIZE))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Could not allocate memory for video BIOS image\n");
+ } else {
+@@ -4173,7 +4196,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Could not find/read video BIOS\n");
+- xfree(pSiS->BIOS);
++ free(pSiS->BIOS);
+ pSiS->BIOS = NULL;
+ }
+ }
+@@ -5559,7 +5582,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ /* Do some MergedFB mode initialisation */
+ #ifdef SISMERGED
+ if(pSiS->MergedFB) {
+- pSiS->CRT2pScrn = xalloc(sizeof(ScrnInfoRec));
++ pSiS->CRT2pScrn = malloc(sizeof(ScrnInfoRec));
+ if(!pSiS->CRT2pScrn) {
+ SISErrorLog(pScrn, "Failed to allocate memory for 2nd pScrn, %s\n", mergeddisstr);
+ pSiS->MergedFB = FALSE;
+@@ -5592,7 +5615,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ } else {
+ SISErrorLog(pScrn, mergednocrt1, mergeddisstr);
+ }
+- if(pSiS->CRT2pScrn) xfree(pSiS->CRT2pScrn);
++ if(pSiS->CRT2pScrn) free(pSiS->CRT2pScrn);
+ pSiS->CRT2pScrn = NULL;
+ pSiS->MergedFB = FALSE;
+ }
+@@ -5639,7 +5662,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ } else {
+ SISErrorLog(pScrn, mergednocrt2, mergeddisstr);
+ }
+- if(pSiS->CRT2pScrn) xfree(pSiS->CRT2pScrn);
++ if(pSiS->CRT2pScrn) free(pSiS->CRT2pScrn);
+ pSiS->CRT2pScrn = NULL;
+ pSiS->MergedFB = FALSE;
+ }
+@@ -6016,7 +6039,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+
+ #ifdef SISMERGED
+ if(pSiS->MergedFB) {
+- pSiS->CRT2pScrn->monitor = xalloc(sizeof(MonRec));
++ pSiS->CRT2pScrn->monitor = malloc(sizeof(MonRec));
+ if(pSiS->CRT2pScrn->monitor) {
+ DisplayModePtr tempm = NULL, currentm = NULL, newm = NULL;
+ memcpy(pSiS->CRT2pScrn->monitor, pScrn->monitor, sizeof(MonRec));
+@@ -6025,10 +6048,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ pSiS->CRT2pScrn->monitor->id = (char *)crt2monname;
+ tempm = pScrn->monitor->Modes;
+ while(tempm) {
+- if(!(newm = xalloc(sizeof(DisplayModeRec)))) break;
++ if(!(newm = malloc(sizeof(DisplayModeRec)))) break;
+ memcpy(newm, tempm, sizeof(DisplayModeRec));
+- if(!(newm->name = xalloc(strlen(tempm->name) + 1))) {
+- xfree(newm);
++ if(!(newm->name = malloc(strlen(tempm->name) + 1))) {
++ free(newm);
+ break;
+ }
+ strcpy(newm->name, tempm->name);
+@@ -6070,7 +6093,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
+ } else {
+ SISErrorLog(pScrn, "Failed to allocate memory for CRT2 monitor, %s.\n",
+ mergeddisstr);
+- if(pSiS->CRT2pScrn) xfree(pSiS->CRT2pScrn);
++ if(pSiS->CRT2pScrn) free(pSiS->CRT2pScrn);
+ pSiS->CRT2pScrn = NULL;
+ pSiS->MergedFB = FALSE;
+ }
+@@ -7454,7 +7477,7 @@ SISVESASaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function)
+ (function == MODE_SAVE)) {
+ /* don't rely on the memory not being touched */
+ if(!pSiS->pstate) {
+- pSiS->pstate = xalloc(pSiS->stateSize);
++ pSiS->pstate = malloc(pSiS->stateSize);
+ }
+ memcpy(pSiS->pstate, pSiS->state, pSiS->stateSize);
+ }
+@@ -8675,7 +8698,7 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+
+ if(pSiS->ShadowFB) {
+ pSiS->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
+- pSiS->ShadowPtr = xalloc(pSiS->ShadowPitch * height);
++ pSiS->ShadowPtr = malloc(pSiS->ShadowPitch * height);
+ displayWidth = pSiS->ShadowPitch / (pScrn->bitsPerPixel >> 3);
+ FBStart = pSiS->ShadowPtr;
+ } else {
+@@ -8849,14 +8872,14 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+
+ pSiS->CRT2ColNum = 1 << pScrn->rgbBits;
+
+- if((pSiS->crt2gcolortable = xalloc(pSiS->CRT2ColNum * 2 * sizeof(LOCO)))) {
++ if((pSiS->crt2gcolortable = malloc(pSiS->CRT2ColNum * 2 * sizeof(LOCO)))) {
+ pSiS->crt2colors = &pSiS->crt2gcolortable[pSiS->CRT2ColNum];
+- if((pSiS->crt2cindices = xalloc(256 * sizeof(int)))) {
++ if((pSiS->crt2cindices = malloc(256 * sizeof(int)))) {
+ int i = pSiS->CRT2ColNum;
+ SISCalculateGammaRampCRT2(pScrn);
+ while(i--) pSiS->crt2cindices[i] = i;
+ } else {
+- xfree(pSiS->crt2gcolortable);
++ free(pSiS->crt2gcolortable);
+ pSiS->crt2gcolortable = NULL;
+ pSiS->CRT2SepGamma = FALSE;
+ }
+@@ -9941,7 +9964,7 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen)
+ if(pSiS->useEXA) {
+ if(pSiS->EXADriverPtr) {
+ exaDriverFini(pScreen);
+- xfree(pSiS->EXADriverPtr);
++ free(pSiS->EXADriverPtr);
+ pSiS->EXADriverPtr = NULL;
+ pSiS->exa_scratch = NULL;
+ }
+@@ -9954,33 +9977,33 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen)
+ }
+
+ if(pSiS->ShadowPtr) {
+- xfree(pSiS->ShadowPtr);
++ free(pSiS->ShadowPtr);
+ pSiS->ShadowPtr = NULL;
+ }
+
+ if(pSiS->DGAModes) {
+- xfree(pSiS->DGAModes);
++ free(pSiS->DGAModes);
+ pSiS->DGAModes = NULL;
+ }
+
+ if(pSiS->adaptor) {
+- xfree(pSiS->adaptor);
++ free(pSiS->adaptor);
+ pSiS->adaptor = NULL;
+ pSiS->ResetXv = pSiS->ResetXvGamma = pSiS->ResetXvDisplay = NULL;
+ }
+
+ if(pSiS->blitadaptor) {
+- xfree(pSiS->blitadaptor);
++ free(pSiS->blitadaptor);
+ pSiS->blitadaptor = NULL;
+ }
+
+ if(pSiS->crt2gcolortable) {
+- xfree(pSiS->crt2gcolortable);
++ free(pSiS->crt2gcolortable);
+ pSiS->crt2gcolortable = NULL;
+ }
+
+ if(pSiS->crt2cindices) {
+- xfree(pSiS->crt2cindices);
++ free(pSiS->crt2cindices);
+ pSiS->crt2cindices = NULL;
+ }
+
+diff --git a/src/sis_memcpy.c b/src/sis_memcpy.c
+index 6ad62e8..3634401 100644
+--- a/src/sis_memcpy.c
++++ b/src/sis_memcpy.c
+@@ -638,13 +638,13 @@ SiS_AllocBuffers(ScrnInfoPtr pScrn, UChar **buf1, UChar **buf2, UChar **buf3)
+ (*buf1) = (UChar *)pSiS->FbBase + offset;
+ (*buf1) = (UChar *)(((ULong)(*buf1) + 31) & ~31);
+
+- if(!((*buf2) = (UChar *)xalloc(BUFFERSIZE + 15))) {
++ if(!((*buf2) = (UChar *)malloc(BUFFERSIZE + 15))) {
+ SISFreeFBMemory(pScrn, &handle);
+ return NULL;
+ }
+
+- if(!((*buf3) = (UChar *)xalloc(BUFFERSIZE + 15))) {
+- xfree((*buf2));
++ if(!((*buf3) = (UChar *)malloc(BUFFERSIZE + 15))) {
++ free((*buf2));
+ SISFreeFBMemory(pScrn, &handle);
+ return NULL;
+ }
+@@ -1098,8 +1098,8 @@ SiSVidCopyInitGen(ScreenPtr pScreen, SISMCFuncData *MCFunctions, vidCopyFunc *UM
+
+ /* Free buffers */
+ SISFreeFBMemory(pScrn, &fbhandle);
+- xfree(buf2);
+- xfree(buf3);
++ free(buf2);
++ free(buf3);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Using %s method for aligned data transfers %s video RAM\n",
+diff --git a/src/sis_opt.c b/src/sis_opt.c
+index 3517549..d39ff6e 100644
+--- a/src/sis_opt.c
++++ b/src/sis_opt.c
+@@ -448,7 +448,7 @@ SiSOptions(ScrnInfoPtr pScrn)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if(!(pSiS->Options = xalloc(sizeof(SISOptions)))) return;
++ if(!(pSiS->Options = malloc(sizeof(SISOptions)))) return;
+
+ memcpy(pSiS->Options, SISOptions, sizeof(SISOptions));
+
+@@ -888,7 +888,7 @@ SiSOptions(ScrnInfoPtr pScrn)
+ if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2POS))) {
+ int result;
+ Bool valid = FALSE;
+- char *tempstr = xalloc(strlen(strptr) + 1);
++ char *tempstr = malloc(strlen(strptr) + 1);
+ result = sscanf(strptr, "%s %d", tempstr, &ival);
+ if(result >= 1) {
+ if(!xf86NameCmp(tempstr,"LeftOf")) {
+@@ -946,18 +946,18 @@ SiSOptions(ScrnInfoPtr pScrn)
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Except for \"Clone\", the parameter may be followed by an integer.\n");
+ }
+- xfree(tempstr);
++ free(tempstr);
+ }
+ if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_METAMODES))) {
+- pSiS->MetaModes = xalloc(strlen(strptr) + 1);
++ pSiS->MetaModes = malloc(strlen(strptr) + 1);
+ if(pSiS->MetaModes) memcpy(pSiS->MetaModes, strptr, strlen(strptr) + 1);
+ }
+ if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC))) {
+- pSiS->CRT2HSync = xalloc(strlen(strptr) + 1);
++ pSiS->CRT2HSync = malloc(strlen(strptr) + 1);
+ if(pSiS->CRT2HSync) memcpy(pSiS->CRT2HSync, strptr, strlen(strptr) + 1);
+ }
+ if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH))) {
+- pSiS->CRT2VRefresh = xalloc(strlen(strptr) + 1);
++ pSiS->CRT2VRefresh = malloc(strlen(strptr) + 1);
+ if(pSiS->CRT2VRefresh) memcpy(pSiS->CRT2VRefresh, strptr, strlen(strptr) + 1);
+ }
+ if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_MERGEDDPI))) {
+diff --git a/src/sis_utility.c b/src/sis_utility.c
+index a9bcd2b..eda194f 100644
+--- a/src/sis_utility.c
++++ b/src/sis_utility.c
+@@ -34,8 +34,6 @@
+ #endif
+
+ #include "sis.h"
+-#define NEED_REPLIES
+-#define NEED_EVENTS
+ #include <X11/X.h>
+ #include "dixstruct.h"
+
+@@ -1882,10 +1880,10 @@ SiSProcSiSCtrlQueryVersion(ClientPtr client)
+ rep.majorVersion = SISCTRL_MAJOR_VERSION;
+ rep.minorVersion = SISCTRL_MINOR_VERSION;
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swaps(&rep.majorVersion, n);
+- swaps(&rep.minorVersion, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swaps(&rep.majorVersion, n);
++ _swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xSiSCtrlQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+@@ -1926,15 +1924,15 @@ SiSProcSiSCtrlCommand(ClientPtr client)
+ rep.sequenceNumber = client->sequence;
+
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swapl(&rep.screen, n);
+- swapl(&rep.sdc_id, n);
+- swapl(&rep.sdc_command, n);
+- swapl(&rep.sdc_result_header, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swapl(&rep.screen, n);
++ _swapl(&rep.sdc_id, n);
++ _swapl(&rep.sdc_command, n);
++ _swapl(&rep.sdc_result_header, n);
+ for(i = 0; i < SDC_NUM_PARM_RESULT; i++) {
+- swapl(&rep.sdc_parm[i], n);
+- swapl(&rep.sdc_result[i], n);
++ _swapl(&rep.sdc_parm[i], n);
++ _swapl(&rep.sdc_result[i], n);
+ }
+ }
+ WriteToClient(client, sizeof(xSiSCtrlCommandReply), (char *)&rep);
+@@ -1961,7 +1959,7 @@ SiSSProcSiSCtrlQueryVersion(ClientPtr client)
+ {
+ REQUEST(xSiSCtrlQueryVersionReq);
+ register int n;
+- swaps(&stuff->length, n);
++ _swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSiSCtrlQueryVersionReq);
+ return SiSProcSiSCtrlQueryVersion(client);
+ }
+@@ -1972,14 +1970,14 @@ SiSSProcSiSCtrlCommand(ClientPtr client)
+ REQUEST(xSiSCtrlCommandReq);
+ register int n;
+ int i;
+- swaps(&stuff->length, n);
+- swapl(&stuff->screen, n);
+- swapl(&stuff->sdc_id, n);
+- swapl(&stuff->sdc_command, n);
+- swapl(&stuff->sdc_result_header, n);
++ _swaps(&stuff->length, n);
++ _swapl(&stuff->screen, n);
++ _swapl(&stuff->sdc_id, n);
++ _swapl(&stuff->sdc_command, n);
++ _swapl(&stuff->sdc_result_header, n);
+ for(i = 0; i < SDC_NUM_PARM_RESULT; i++) {
+- swapl(&stuff->sdc_parm[i], n);
+- swapl(&stuff->sdc_result[i], n);
++ _swapl(&stuff->sdc_parm[i], n);
++ _swapl(&stuff->sdc_result[i], n);
+ }
+ REQUEST_SIZE_MATCH(xSiSCtrlCommandReq);
+ return SiSProcSiSCtrlCommand(client);
+@@ -2007,7 +2005,7 @@ SiSCtrlResetProc(ExtensionEntry* extEntry)
+ * in SiSCtrlExtUnregister())
+ */
+ if(extEntry->extPrivate) {
+- xfree(extEntry->extPrivate);
++ free(extEntry->extPrivate);
+ extEntry->extPrivate = NULL;
+ }
+ }
+@@ -2028,7 +2026,7 @@ SiSCtrlExtInit(ScrnInfoPtr pScrn)
+
+ if(!(myext = CheckExtension(SISCTRL_PROTOCOL_NAME))) {
+
+- if(!(myctrl = xcalloc(sizeof(xSiSCtrlScreenTable), 1)))
++ if(!(myctrl = calloc(sizeof(xSiSCtrlScreenTable), 1)))
+ return;
+
+ if(!(myext = AddExtension(SISCTRL_PROTOCOL_NAME, 0, 0,
+@@ -2038,7 +2036,7 @@ SiSCtrlExtInit(ScrnInfoPtr pScrn)
+ StandardMinorOpcode))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to add SISCTRL extension\n");
+- xfree(myctrl);
++ free(myctrl);
+ return;
+ }
+
+diff --git a/src/sis_vga.c b/src/sis_vga.c
+index 3f6219b..4c887b8 100644
+--- a/src/sis_vga.c
++++ b/src/sis_vga.c
+@@ -1429,7 +1429,7 @@ SiSVGASaveFonts(ScrnInfoPtr pScrn)
+ attr10 = SiS_ReadAttr(pSiS, 0x10);
+ if(attr10 & 0x01) return;
+
+- if(!(pSiS->fonts = xalloc(SIS_FONTS_SIZE * 2))) {
++ if(!(pSiS->fonts = malloc(SIS_FONTS_SIZE * 2))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Could not save console fonts, mem allocation failed\n");
+ return;
+@@ -1716,8 +1716,8 @@ SiSVGAMapMem(ScrnInfoPtr pScrn)
+
+ #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
+ #if XSERVER_LIBPCIACCESS
+- pSiS->VGAMemBase = xf86MapDomainMemory(pScrn->scrnIndex, VIDMEM_MMIO_32BIT,
+- pSiS->PciInfo, pSiS->VGAMapPhys, pSiS->VGAMapSize);
++ (void) pci_device_map_legacy(pSiS->PciInfo, pSiS->VGAMapPhys, pSiS->VGAMapSize,
++ PCI_DEV_MAP_FLAG_WRITABLE, &pSiS->VGAMemBase);
+ #else
+ pSiS->VGAMemBase = xf86MapDomainMemory(pScrn->scrnIndex, VIDMEM_MMIO_32BIT,
+ pSiS->PciTag, pSiS->VGAMapPhys, pSiS->VGAMapSize);
+@@ -1737,7 +1737,12 @@ SiSVGAUnmapMem(ScrnInfoPtr pScrn)
+
+ if(pSiS->VGAMemBase == NULL) return;
+
++#if XSERVER_LIBPCIACCESS
++ (void) pci_device_unmap_legacy(pSiS->PciInfo, pSiS->VGAMemBase, pSiS->VGAMapSize);
++#else
+ xf86UnMapVidMem(pScrn->scrnIndex, pSiS->VGAMemBase, pSiS->VGAMapSize);
++#endif
++
+ pSiS->VGAMemBase = NULL;
+ }
+ #endif
+diff --git a/src/sis_video.c b/src/sis_video.c
+index 7322efb..2006858 100644
+--- a/src/sis_video.c
++++ b/src/sis_video.c
+@@ -326,7 +326,7 @@ SISInitVideo(ScreenPtr pScreen)
+ if(newAdaptor) size++;
+ if(newBlitAdaptor) size++;
+
+- newAdaptors = xalloc(size * sizeof(XF86VideoAdaptorPtr*));
++ newAdaptors = malloc(size * sizeof(XF86VideoAdaptorPtr*));
+ if(newAdaptors) {
+ if(num_adaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr));
+@@ -356,7 +356,7 @@ SISInitVideo(ScreenPtr pScreen)
+ }
+
+ if(newAdaptors) {
+- xfree(newAdaptors);
++ free(newAdaptors);
+ }
+ }
+
+@@ -877,7 +877,7 @@ SISSetupImageVideo(ScreenPtr pScreen)
+ }
+ #endif
+
+- if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
++ if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
+ sizeof(SISPortPrivRec) +
+ sizeof(DevUnion)))) {
+ return NULL;
+@@ -4067,7 +4067,7 @@ SISSetupBlitVideo(ScreenPtr pScreen)
+ }
+ #endif
+
+- if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
++ if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
+ (sizeof(DevUnion) * NUM_BLIT_PORTS) +
+ sizeof(SISBPortPrivRec)))) {
+ return NULL;
+diff --git a/src/sispcirename.h b/src/sispcirename.h
+index c4beac6..54cc07f 100644
+--- a/src/sispcirename.h
++++ b/src/sispcirename.h
+@@ -29,11 +29,35 @@
+ #ifndef SISPCIRENAME_H
+ #define SISPCIRENAME_H
+
++#include <stdint.h>
++
+ enum region_type {
+ REGION_MEM,
+ REGION_IO
+ };
+
++#if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
++#define PCI_DOM_MASK 0x01fful
++#else
++#define PCI_DOM_MASK 0x0ffu
++#endif
++
++#ifndef PCI_DOM_MASK
++# define PCI_DOM_MASK 0x0ffu
++#endif
++#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
++
++static inline uint32_t
++pciTag(int busnum, int devnum, int funcnum)
++{
++ uint32_t tag;
++ tag = (busnum & (PCI_DOMBUS_MASK)) << 16;
++ tag |= (devnum & 0x00001fu) << 11;
++ tag |= (funcnum & 0x000007u) << 8;
++
++ return tag;
++}
++
+ #ifndef XSERVER_LIBPCIACCESS
+
+ /* pciVideoPtr */
+diff --git a/src/vgatypes.h b/src/vgatypes.h
+index 4be31e4..d6e7b6e 100644
+--- a/src/vgatypes.h
++++ b/src/vgatypes.h
+@@ -69,8 +69,9 @@ typedef unsigned int BOOLEAN;
+
+ #define SISIOMEMTYPE
+
+-#ifdef SIS_LINUX_KERNEL
+ typedef unsigned long SISIOADDRESS;
++
++#ifdef SIS_LINUX_KERNEL
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8)
+ #include <linux/types.h> /* Need __iomem */
+ #undef SISIOMEMTYPE
+@@ -78,15 +79,6 @@ typedef unsigned long SISIOADDRESS;
+ #endif
+ #endif
+
+-#ifdef SIS_XORG_XF86
+-#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,0,0,0)
+-typedef unsigned long IOADDRESS;
+-typedef unsigned long SISIOADDRESS;
+-#else
+-typedef IOADDRESS SISIOADDRESS;
+-#endif
+-#endif
+-
+ typedef enum _SIS_CHIP_TYPE {
+ SIS_VGALegacy = 0,
+ SIS_530,
diff --git a/staging/xf86-video-sisusb/PKGBUILD b/staging/xf86-video-sisusb/PKGBUILD
new file mode 100644
index 000000000..02929949f
--- /dev/null
+++ b/staging/xf86-video-sisusb/PKGBUILD
@@ -0,0 +1,33 @@
+# $Id: PKGBUILD 149884 2012-02-11 11:45:36Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-sisusb
+pkgver=0.9.4
+pkgrel=6
+pkgdesc="X.org SiS USB video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ sisusb-0.9.4-git.patch)
+sha1sums=('600fd49dffe00121f9042555fea55948653d1a7e'
+ 'd74ce7732889c7a00d9d2dcd2bfc8be05c6eb912')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/sisusb-0.9.4-git.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-sisusb/sisusb-0.9.4-git.patch b/staging/xf86-video-sisusb/sisusb-0.9.4-git.patch
new file mode 100644
index 000000000..24474954a
--- /dev/null
+++ b/staging/xf86-video-sisusb/sisusb-0.9.4-git.patch
@@ -0,0 +1,794 @@
+diff --git a/configure.ac b/configure.ac
+index 86c6ac5..725d6cb 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,49 +20,48 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-sisusb],
+- 0.9.4,
++ [0.9.4],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-sisusb)
+-
++ [xf86-video-sisusb])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
++# Initialize Automake
+ AM_INIT_AUTOMAKE([foreign dist-bzip2])
+-
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_DEFAULT_OPTIONS
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+ m4_ifndef([XORG_MACROS_VERSION],
+- [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.3)
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
+ XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+-XORG_PROG_RAWCPP
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto)
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
+-PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
++# Obtain compiler/linker options for the driver dependencies
++PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto pciaccess $REQUIRED_MODULES])
+ PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+ HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
+ HAVE_XEXTPROTO_71="no")
+@@ -70,17 +69,14 @@ AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes" ])
+
+ # Checks for libraries.
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=sisusb
+ AC_SUBST([DRIVER_NAME])
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 1b26ac2..9ceb36f 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -31,39 +31,9 @@ EXTRA_DIST = @DRIVER_NAME@.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+-
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
+-
+-MANDEFS = \
+- -D__vendorversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \
+- -D__appmansuffix__=$(APP_MAN_SUFFIX) \
+- -D__filemansuffix__=$(FILE_MAN_SUFFIX) \
+- -D__libmansuffix__=$(LIB_MAN_SUFFIX) \
+- -D__miscmansuffix__=$(MISC_MAN_SUFFIX) \
+- -D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \
+- -D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \
+- -D__xconfigfile__=xorg.conf \
+- -D__xservername__=Xorg
+-
+-# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM
+-# to cpp, because that trick does not work on all ANSI C preprocessors.
+-# Delete line numbers from the cpp output (-P is not portable, I guess).
+-# Allow XCOMM to be preceded by whitespace and provide a means of generating
+-# output lines with trailing backslashes.
+-# Allow XHASH to always be substituted, even in cases where XCOMM isn't.
+-
+-CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \
+- -e '/^\#line *[0-9][0-9]* *.*$$/d' \
+- -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \
+- -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
+- -e '/^[ ]*XHASH/s/XHASH/\#/' \
+- -e '/\@\@$$/s/\@\@$$/\\/'
+-
+ SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+ .man.$(DRIVER_MAN_SUFFIX):
+- $(RAWCPP) $(RAWCPPFLAGS) $(MANDEFS) $(EXTRAMANDEFS) < $< | $(CPP_SED_MAGIC) > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+
+diff --git a/man/sisusb.man b/man/sisusb.man
+index 7817cb5..6eafb8e 100644
+--- a/man/sisusb.man
++++ b/man/sisusb.man
+@@ -1,17 +1,5 @@
+-.\" $XFree86$
+-.\" $XdotOrg$
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+-#ifdef __xservername__
+-#define __myservername__ __xservername__
+-#else
+-#define __myservername__ XFree86
+-#endif
+-#ifdef __xconfigfile__
+-#define __myxconfigfile__ __xconfigfile__
+-#else
+-#define __myxconfigfile__ XF86Config
+-#endif
+ .TH SISUSB __drivermansuffix__ __vendorversion__
+ .SH NAME
+ sisusb \- SiS USB video driver
+@@ -25,7 +13,7 @@ sisusb \- SiS USB video driver
+ .fi
+ .SH DESCRIPTION
+ .B sisusb
+-is an __myservername__ driver for SiS (Silicon Integrated Systems) video chips that
++is an __xservername__ driver for SiS (Silicon Integrated Systems) video chips that
+ are connected via a Net2280-based USB dongle. The driver is not accelerated, but
+ provides support for colordepths of 8, 16 and 24 bpp as well as Render and other
+ extensions.
+@@ -39,7 +27,7 @@ driver supports USB video cards based on the following chipsets:
+ The SiS315E/PRO features two CRT controllers. However, in its USB version, only
+ the first output, referred to as "CRT1", is being used.
+ .SH CONFIGURATION DETAILS
+-Please refer to __myxconfigfile__(__filemansuffix__) for general configuration
++Please refer to __xconfigfile__(__filemansuffix__) for general configuration
+ details and to sis(__drivermansuffix__) for more information. This manpage only
+ covers a subset of the supported options.
+ .PP
+@@ -81,11 +69,7 @@ for device reconnection).
+ .SH "KNOWN BUGS"
+ none.
+ .SH "SEE ALSO"
+-#ifdef __xservername__
+ __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__), sis(__drivermansuffix__)
+-#else
+-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__), sis(__drivermansuffix__)
+-#endif
+ .PP
+ .B "http://www.winischhofer.at/linuxsisvga.shtml"
+ for more information and updates
+diff --git a/src/sisusb.h b/src/sisusb.h
+index b9992ac..82ed509 100644
+--- a/src/sisusb.h
++++ b/src/sisusb.h
+@@ -113,6 +113,14 @@
+ #include <X11/extensions/Xv.h>
+ #endif
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++#define _swapl(x, n) swapl(x,n)
++#define _swaps(x, n) swaps(x,n)
++#else
++#define _swapl(x, n) swapl(x)
++#define _swaps(x, n) swaps(x)
++#endif
++
+ /* Platform/architecture related definitions: */
+
+ #undef SIS_PC_PLATFORM
+@@ -141,7 +149,6 @@
+ #define UNLOCK_ALWAYS /* Always unlock the registers (should be set!) */
+
+ /* Need that for SiSCtrl */
+-#define NEED_REPLIES /* ? */
+ #define EXTENSION_PROC_ARGS void *
+ #include "extnsionst.h" /* required */
+ #include <X11/extensions/panoramiXproto.h> /* required */
+@@ -732,7 +739,7 @@ typedef struct {
+ Bool skipswitchcheck;
+ ULong VBFlagsInit;
+ DisplayModePtr currentModeLast;
+- IOADDRESS MyPIOOffset;
++ unsigned long MyPIOOffset;
+
+ char messagebuffer[64];
+ unsigned int VGAMapSize; /* SiSVGA stuff */
+diff --git a/src/sisusb_dac.c b/src/sisusb_dac.c
+index 5e3eb7f..b5c4dce 100644
+--- a/src/sisusb_dac.c
++++ b/src/sisusb_dac.c
+@@ -672,7 +672,7 @@ SiSUSBMemCopyToVideoRam(SISUSBPtr pSiSUSB, UChar *to, UChar *from, int size)
+ int num, retry = 3;
+ if(pSiSUSB->sisusbfatalerror) return;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)to, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)to, SEEK_SET);
+ num = write(pSiSUSB->sisusbdev, from, size);
+ } while((num != size) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+@@ -958,7 +958,7 @@ void sisclearvram(SISUSBPtr pSiSUSB, UChar *where, unsigned int howmuch)
+ if(pSiSUSB->sisusbfatalerror) return;
+ do {
+ x.operation = SUCMD_CLRSCR;
+- x.data3 = (CARD32)where;
++ x.data3 = (CARD32)(uintptr_t)where;
+ x.data0 = (howmuch >> 16) & 0xff;
+ x.data1 = (howmuch >> 8) & 0xff;
+ x.data2 = howmuch & 0xff;
+@@ -990,7 +990,7 @@ void SIS_MMIO_OUT8(SISUSBPtr pSiSUSB, UChar *base, unsigned int offset, CARD8 va
+ int num, retry = 3;
+ if(pSiSUSB->sisusbfatalerror) return;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)base + offset, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)base + offset, SEEK_SET);
+ num = write(pSiSUSB->sisusbdev, &val, 1);
+ } while((num != 1) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+@@ -1002,7 +1002,7 @@ void SIS_MMIO_OUT16(SISUSBPtr pSiSUSB, UChar *base, unsigned int offset, CARD16
+ CARD16 buf = sisusb_cpu_to_le16(val);
+ if(pSiSUSB->sisusbfatalerror) return;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)base + offset, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)base + offset, SEEK_SET);
+ num = write(pSiSUSB->sisusbdev, &buf, 2);
+ } while((num != 2) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+@@ -1014,7 +1014,7 @@ void SIS_MMIO_OUT32(SISUSBPtr pSiSUSB, UChar *base, unsigned int offset, CARD32
+ CARD32 buf = sisusb_cpu_to_le32(val);
+ if(pSiSUSB->sisusbfatalerror) return;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)base + offset, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)base + offset, SEEK_SET);
+ num = write(pSiSUSB->sisusbdev, &buf, 4);
+ } while((num != 4) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+@@ -1026,7 +1026,7 @@ CARD8 SIS_MMIO_IN8(SISUSBPtr pSiSUSB, UChar *base, unsigned int offset)
+ CARD8 tmp;
+ if(pSiSUSB->sisusbfatalerror) return 0;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)base + offset, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)base + offset, SEEK_SET);
+ num = read(pSiSUSB->sisusbdev, &tmp, 1);
+ } while((num != 1) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+@@ -1039,7 +1039,7 @@ CARD16 SIS_MMIO_IN16(SISUSBPtr pSiSUSB, UChar *base, unsigned int offset)
+ CARD16 tmp;
+ if(pSiSUSB->sisusbfatalerror) return 0;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)base + offset, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)base + offset, SEEK_SET);
+ num = read(pSiSUSB->sisusbdev, &tmp, 2);
+ } while((num != 2) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+@@ -1052,7 +1052,7 @@ CARD32 SIS_MMIO_IN32(SISUSBPtr pSiSUSB, UChar *base, unsigned int offset)
+ CARD32 tmp;
+ if(pSiSUSB->sisusbfatalerror) return 0;
+ do {
+- lseek(pSiSUSB->sisusbdev, (int)base + offset, SEEK_SET);
++ lseek(pSiSUSB->sisusbdev, (uintptr_t)base + offset, SEEK_SET);
+ num = read(pSiSUSB->sisusbdev, &tmp, 4);
+ } while((num != 4) && --retry);
+ if(!retry) SiSLostConnection(pSiSUSB);
+diff --git a/src/sisusb_driver.c b/src/sisusb_driver.c
+index 8ba2c33..032225c 100644
+--- a/src/sisusb_driver.c
++++ b/src/sisusb_driver.c
+@@ -186,12 +186,12 @@ SISUSBFreeRec(ScrnInfoPtr pScrn)
+ /* Just to make sure... */
+ if(!pSiSUSB) return;
+
+- if(pSiSUSB->pstate) xfree(pSiSUSB->pstate);
++ if(pSiSUSB->pstate) free(pSiSUSB->pstate);
+ pSiSUSB->pstate = NULL;
+- if(pSiSUSB->fonts) xfree(pSiSUSB->fonts);
++ if(pSiSUSB->fonts) free(pSiSUSB->fonts);
+ pSiSUSB->fonts = NULL;
+
+- if(pSiSUSB->SiS_Pr) xfree(pSiSUSB->SiS_Pr);
++ if(pSiSUSB->SiS_Pr) free(pSiSUSB->SiS_Pr);
+ pSiSUSB->SiS_Pr = NULL;
+
+ if(pSiSUSB->sisusbdevopen) {
+@@ -200,12 +200,12 @@ SISUSBFreeRec(ScrnInfoPtr pScrn)
+ }
+
+ if(pScrn->chipset) {
+- xfree(pScrn->chipset);
++ free(pScrn->chipset);
+ pScrn->chipset = NULL;
+ }
+
+ if(pScrn->driverPrivate) {
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+ }
+@@ -217,14 +217,14 @@ SISUSBErrorLog(ScrnInfoPtr pScrn, const char *format, ...)
+ static const char *str = "**************************************************\n";
+
+ va_start(ap, format);
+- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, str);
++ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s", str);
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ " ERROR:\n");
+ xf86VDrvMsgVerb(pScrn->scrnIndex, X_ERROR, 1, format, ap);
+ va_end(ap);
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ " END OF MESSAGE\n");
+- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, str);
++ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s", str);
+ }
+
+ static int
+@@ -248,7 +248,7 @@ SiSUSBCheckForUSBDongle(char *filename, SISUSBPtr pSiSUSB, int *filehandle)
+
+ if((myfile = open(filename, O_RDWR, 0)) != -1) {
+ if(!ioctl(myfile, SISUSB_GET_CONFIG_SIZE, &sisusbinfosize)) {
+- if((mysisusbinfo = xalloc(sisusbinfosize))) {
++ if((mysisusbinfo = malloc(sisusbinfosize))) {
+ if(!ioctl(myfile, (SISUSB_GET_CONFIG | (sisusbinfosize << 16)), mysisusbinfo)) {
+ if(mysisusbinfo->sisusb_id == SISUSB_ID) {
+ sisusbversion = (mysisusbinfo->sisusb_version << 16) |
+@@ -280,7 +280,7 @@ SiSUSBCheckForUSBDongle(char *filename, SISUSBPtr pSiSUSB, int *filehandle)
+ retval = mysisusbinfo->sisusb_minor;
+ }
+ }
+- xfree(mysisusbinfo);
++ free(mysisusbinfo);
+ mysisusbinfo = NULL;
+ }
+ }
+@@ -307,13 +307,13 @@ SiSUSBFindUSBDongle(GDevPtr dev, int *minorArray, int numDevSections, char **nam
+ }
+ if((p) && (*p) && (*p == '/')) {
+ gotdev = 1;
+- *nameptr = xalloc(strlen(p) + 1);
++ *nameptr = malloc(strlen(p) + 1);
+ strcpy(*nameptr, p);
+ retval = SiSUSBCheckForUSBDongle(*nameptr, NULL, NULL);
+ } else if((p) && (*p) && (sscanf(p, "%d", &i) == 1)) {
+ if(i >= 0 && i <= 31) {
+ gotdev = 1;
+- *nameptr = xalloc(32);
++ *nameptr = malloc(32);
+ sprintf(*nameptr, "/dev/sisusbvga%d", i);
+ retval = SiSUSBCheckForUSBDongle(*nameptr, NULL, NULL);
+ if(retval < 0) {
+@@ -324,7 +324,7 @@ SiSUSBFindUSBDongle(GDevPtr dev, int *minorArray, int numDevSections, char **nam
+ }
+ }
+ if(!gotdev) {
+- *nameptr = xalloc(32);
++ *nameptr = malloc(32);
+ for(i = 0; i < 64; i++) {
+ if(i < 32) sprintf(*nameptr, "/dev/sisusbvga%d", i);
+ else sprintf(*nameptr, "/dev/usb/sisusbvga%d", i);
+@@ -338,7 +338,7 @@ SiSUSBFindUSBDongle(GDevPtr dev, int *minorArray, int numDevSections, char **nam
+ if(retval >= 0) {
+ xf86Msg(X_INFO, "Found SiSUSB dongle (node %s, minor %d)\n", *nameptr, retval);
+ } else if((*nameptr)) {
+- xfree(*nameptr);
++ free(*nameptr);
+ *nameptr = NULL;
+ }
+
+@@ -401,14 +401,14 @@ SISUSBProbe(DriverPtr drv, int flags)
+ */
+
+ /* Allocate and initialize an array of ints for storing the minors */
+- if(!(minorArray = (int *)xalloc(numDevSections * sizeof(int)))) {
++ if(!(minorArray = (int *)malloc(numDevSections * sizeof(int)))) {
+ return FALSE;
+ }
+ for(i = 0; i < numDevSections; i++) minorArray[i] = -1;
+
+ /* Allocate an array of char ptrs for storing the device node names */
+- if(!(devnameArray = (char **)xalloc(numDevSections * sizeof(char *)))) {
+- xfree(minorArray);
++ if(!(devnameArray = (char **)malloc(numDevSections * sizeof(char *)))) {
++ free(minorArray);
+ return FALSE;
+ }
+
+@@ -420,20 +420,20 @@ SISUSBProbe(DriverPtr drv, int flags)
+ if((myminor = SiSUSBFindUSBDongle(devSections[i], minorArray, numDevSections, &nameptr)) >= 0) {
+ if(!SiSUSBFindDuplicate(myminor, minorArray, numDevSections)) {
+ minorArray[numUsed] = myminor;
+- devnameArray[numUsed] = xalloc(strlen(nameptr) + 1);
++ devnameArray[numUsed] = malloc(strlen(nameptr) + 1);
+ strcpy(devnameArray[numUsed], nameptr);
+ numUsed++;
+ }
+- xfree(nameptr);
++ free(nameptr);
+ }
+ }
+
+ /* Free the minor array, we don't need it anymore */
+- xfree(minorArray);
++ free(minorArray);
+
+ if(numUsed <= 0) {
+- xfree(devSections);
+- xfree(devnameArray);
++ free(devSections);
++ free(devnameArray);
+ return FALSE;
+ }
+
+@@ -470,8 +470,8 @@ SISUSBProbe(DriverPtr drv, int flags)
+
+ }
+
+- xfree(devSections);
+- xfree(devnameArray);
++ free(devSections);
++ free(devnameArray);
+ return foundScreen;
+ }
+
+@@ -622,10 +622,10 @@ SISUSBCalculateGammaRamp(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+ if(!(nramp = xf86GetGammaRampSize(pScreen))) return;
+
+ for(i=0; i<3; i++) {
+- ramp[i] = (UShort *)xalloc(nramp * sizeof(UShort));
++ ramp[i] = (UShort *)malloc(nramp * sizeof(UShort));
+ if(!ramp[i]) {
+- if(ramp[0]) { xfree(ramp[0]); ramp[0] = NULL; }
+- if(ramp[1]) { xfree(ramp[1]); ramp[1] = NULL; }
++ if(ramp[0]) { free(ramp[0]); ramp[0] = NULL; }
++ if(ramp[1]) { free(ramp[1]); ramp[1] = NULL; }
+ return;
+ }
+ }
+@@ -685,9 +685,9 @@ SISUSBCalculateGammaRamp(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+
+ xf86ChangeGammaRamp(pScreen, nramp, ramp[0], ramp[1], ramp[2]);
+
+- xfree(ramp[0]);
+- xfree(ramp[1]);
+- xfree(ramp[2]);
++ free(ramp[0]);
++ free(ramp[1]);
++ free(ramp[2]);
+ ramp[0] = ramp[1] = ramp[2] = NULL;
+ }
+ #endif
+@@ -906,11 +906,11 @@ SISUSBPreInit(ScrnInfoPtr pScrn, int flags)
+ Bool gotit = FALSE;
+
+ if(!ioctl(fd, SISUSBFB_GET_INFO_SIZE, &sisfbinfosize)) {
+- if((mysisfbinfo = xalloc(sisfbinfosize))) {
++ if((mysisfbinfo = malloc(sisfbinfosize))) {
+ if(!ioctl(fd, (SISUSBFB_GET_INFO | (sisfbinfosize << 16)), mysisfbinfo)) {
+ gotit = TRUE;
+ } else {
+- xfree(mysisfbinfo);
++ free(mysisfbinfo);
+ mysisfbinfo = NULL;
+ }
+ }
+@@ -944,7 +944,7 @@ SISUSBPreInit(ScrnInfoPtr pScrn, int flags)
+
+ }
+ }
+- xfree(mysisfbinfo);
++ free(mysisfbinfo);
+ mysisfbinfo = NULL;
+ }
+ close (fd);
+@@ -1147,7 +1147,7 @@ SISUSBPreInit(ScrnInfoPtr pScrn, int flags)
+ #endif
+
+ if(pSiSUSB->HWCursor) {
+- if(!(pSiSUSB->USBCursorBuf = xcalloc(pSiSUSB->CursorSize * 4, 1))) pSiSUSB->HWCursor = FALSE;
++ if(!(pSiSUSB->USBCursorBuf = calloc(pSiSUSB->CursorSize * 4, 1))) pSiSUSB->HWCursor = FALSE;
+
+ pSiSUSB->availMem -= (pSiSUSB->CursorSize * 2);
+ if(pSiSUSB->OptUseColorCursor) pSiSUSB->availMem -= (pSiSUSB->CursorSize * 2);
+@@ -1456,8 +1456,8 @@ SISUSBMapMem(ScrnInfoPtr pScrn)
+ {
+ SISUSBPtr pSiSUSB = SISUSBPTR(pScrn);
+
+- pSiSUSB->FbBase = (UChar *)pSiSUSB->FbAddress;
+- pSiSUSB->IOBase = (UChar *)pSiSUSB->IOAddress;
++ pSiSUSB->FbBase = (UChar *)(uintptr_t)pSiSUSB->FbAddress;
++ pSiSUSB->IOBase = (UChar *)(uintptr_t)pSiSUSB->IOAddress;
+
+ return TRUE;
+ }
+@@ -1811,7 +1811,7 @@ SISUSBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+
+ if(pSiSUSB->ShadowFB) {
+ pSiSUSB->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * displayWidth);
+- pSiSUSB->ShadowPtr = xalloc(pSiSUSB->ShadowPitch * height);
++ pSiSUSB->ShadowPtr = malloc(pSiSUSB->ShadowPitch * height);
+ if(!(FBStart = pSiSUSB->ShadowPtr)) {
+ SISUSBSaveScreen(pScreen, SCREEN_SAVER_OFF);
+ SISUSBErrorLog(pScrn, "Failed to allocate shadow framebuffer\n");
+@@ -1820,7 +1820,7 @@ SISUSBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ #if X_BYTE_ORDER == X_BIG_ENDIAN
+ if(pScrn->bitsPerPixel == 16) {
+ /* For 16bpp, we need to swap the bytes in the framebuffer */
+- if(!(pSiSUSB->ShadowPtrSwap = xalloc(pSiSUSB->ShadowPitch * height))) {
++ if(!(pSiSUSB->ShadowPtrSwap = malloc(pSiSUSB->ShadowPitch * height))) {
+ SISUSBSaveScreen(pScreen, SCREEN_SAVER_OFF);
+ SISUSBErrorLog(pScrn, "Failed to allocate swap buffer for shadow framebuffer\n");
+ return FALSE;
+@@ -2238,24 +2238,24 @@ SISUSBCloseScreen(int scrnIndex, ScreenPtr pScreen)
+ }
+
+ if(pSiSUSB->USBCursorBuf) {
+- xfree(pSiSUSB->USBCursorBuf);
++ free(pSiSUSB->USBCursorBuf);
+ pSiSUSB->USBCursorBuf = NULL;
+ }
+
+ if(pSiSUSB->ShadowPtr) {
+- xfree(pSiSUSB->ShadowPtr);
++ free(pSiSUSB->ShadowPtr);
+ pSiSUSB->ShadowPtr = NULL;
+ }
+
+ #if 0
+ if(pSiSUSB->PreAllocMem) {
+- xfree(pSiSUSB->PreAllocMem);
++ free(pSiSUSB->PreAllocMem);
+ pSiSUSB->PreAllocMem = NULL;
+ }
+ #endif
+
+ if(pSiSUSB->adaptor) {
+- xfree(pSiSUSB->adaptor);
++ free(pSiSUSB->adaptor);
+ pSiSUSB->adaptor = NULL;
+ pSiSUSB->ResetXv = pSiSUSB->ResetXvGamma = NULL;
+ }
+diff --git a/src/sisusb_init.c b/src/sisusb_init.c
+index ba44431..99ec519 100644
+--- a/src/sisusb_init.c
++++ b/src/sisusb_init.c
+@@ -1301,10 +1301,10 @@ SiSUSBBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN i
+ }
+ }
+
+- if(!(new = xalloc(sizeof(DisplayModeRec)))) return first;
++ if(!(new = malloc(sizeof(DisplayModeRec)))) return first;
+ memset(new, 0, sizeof(DisplayModeRec));
+- if(!(new->name = xalloc(10))) {
+- xfree(new);
++ if(!(new->name = malloc(10))) {
++ free(new);
+ return first;
+ }
+ if(!first) first = new;
+diff --git a/src/sisusb_opt.c b/src/sisusb_opt.c
+index d4612b0..4d5cfa3 100644
+--- a/src/sisusb_opt.c
++++ b/src/sisusb_opt.c
+@@ -228,7 +228,7 @@ SiSUSBOptions(ScrnInfoPtr pScrn)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if(!(pSiSUSB->Options = xalloc(sizeof(SISUSBOptions)))) return;
++ if(!(pSiSUSB->Options = malloc(sizeof(SISUSBOptions)))) return;
+
+ memcpy(pSiSUSB->Options, SISUSBOptions, sizeof(SISUSBOptions));
+
+diff --git a/src/sisusb_osdef.h b/src/sisusb_osdef.h
+index 2d938ad..500bffb 100644
+--- a/src/sisusb_osdef.h
++++ b/src/sisusb_osdef.h
+@@ -77,11 +77,11 @@
+
+ #define SIS315H
+
+-#define OutPortByte(p,v) outSISREG((IOADDRESS)(p),(CARD8)(v))
+-#define OutPortWord(p,v) outSISREGW((IOADDRESS)(p),(CARD16)(v))
+-#define OutPortLong(p,v) outSISREGL((IOADDRESS)(p),(CARD32)(v))
+-#define InPortByte(p) inSISREG((IOADDRESS)(p))
+-#define InPortWord(p) inSISREGW((IOADDRESS)(p))
+-#define InPortLong(p) inSISREGL((IOADDRESS)(p))
++#define OutPortByte(p,v) outSISREG((unsigned long)(p),(CARD8)(v))
++#define OutPortWord(p,v) outSISREGW((unsigned long)(p),(CARD16)(v))
++#define OutPortLong(p,v) outSISREGL((unsigned long)(p),(CARD32)(v))
++#define InPortByte(p) inSISREG((unsigned long)(p))
++#define InPortWord(p) inSISREGW((unsigned long)(p))
++#define InPortLong(p) inSISREGL((unsigned long)(p))
+
+ #endif /* _SISUSB_OSDEF_H_ */
+diff --git a/src/sisusb_types.h b/src/sisusb_types.h
+index 04c7a7a..9fc6b41 100644
+--- a/src/sisusb_types.h
++++ b/src/sisusb_types.h
+@@ -51,6 +51,8 @@
+ #ifndef _VGATYPES_
+ #define _VGATYPES_
+
++#include <xf86Pci.h>
++
+ #ifndef FALSE
+ #define FALSE 0
+ #endif
+@@ -93,7 +95,7 @@ typedef unsigned char BOOLEAN;
+
+ #define SISIOMEMTYPE
+
+-typedef IOADDRESS SISIOADDRESS;
++typedef unsigned long SISIOADDRESS;
+
+ typedef enum _SIS_CHIP_TYPE {
+ SIS_VGALegacy = 0,
+diff --git a/src/sisusb_utility.c b/src/sisusb_utility.c
+index 8c03d63..a9c1ee1 100644
+--- a/src/sisusb_utility.c
++++ b/src/sisusb_utility.c
+@@ -34,8 +34,6 @@
+ #endif
+
+ #include "sisusb.h"
+-#define NEED_REPLIES
+-#define NEED_EVENTS
+ #include <X11/X.h>
+ #include "dixstruct.h"
+
+@@ -789,10 +787,10 @@ SiSUSBProcSiSCtrlQueryVersion(ClientPtr client)
+ rep.majorVersion = SISCTRL_MAJOR_VERSION;
+ rep.minorVersion = SISCTRL_MINOR_VERSION;
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swaps(&rep.majorVersion, n);
+- swaps(&rep.minorVersion, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swaps(&rep.majorVersion, n);
++ _swaps(&rep.minorVersion, n);
+ }
+ WriteToClient(client, sizeof(xSiSCtrlQueryVersionReply), (char *)&rep);
+ return (client->noClientException);
+@@ -834,15 +832,15 @@ SiSUSBProcSiSCtrlCommand(ClientPtr client)
+ rep.sequenceNumber = client->sequence;
+
+ if(client->swapped) {
+- swaps(&rep.sequenceNumber, n);
+- swapl(&rep.length, n);
+- swapl(&rep.screen, n);
+- swapl(&rep.sdc_id, n);
+- swapl(&rep.sdc_command, n);
+- swapl(&rep.sdc_result_header, n);
++ _swaps(&rep.sequenceNumber, n);
++ _swapl(&rep.length, n);
++ _swapl(&rep.screen, n);
++ _swapl(&rep.sdc_id, n);
++ _swapl(&rep.sdc_command, n);
++ _swapl(&rep.sdc_result_header, n);
+ for(i = 0; i < SDC_NUM_PARM_RESULT; i++) {
+- swapl(&rep.sdc_parm[i], n);
+- swapl(&rep.sdc_result[i], n);
++ _swapl(&rep.sdc_parm[i], n);
++ _swapl(&rep.sdc_result[i], n);
+ }
+ }
+ WriteToClient(client, sizeof(xSiSCtrlCommandReply), (char *)&rep);
+@@ -869,7 +867,7 @@ SiSUSBSProcSiSCtrlQueryVersion(ClientPtr client)
+ {
+ REQUEST(xSiSCtrlQueryVersionReq);
+ register int n;
+- swaps(&stuff->length, n);
++ _swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSiSCtrlQueryVersionReq);
+ return SiSUSBProcSiSCtrlQueryVersion(client);
+ }
+@@ -880,14 +878,14 @@ SiSUSBSProcSiSCtrlCommand(ClientPtr client)
+ REQUEST(xSiSCtrlCommandReq);
+ register int n;
+ int i;
+- swaps(&stuff->length, n);
+- swapl(&stuff->screen, n);
+- swapl(&stuff->sdc_id, n);
+- swapl(&stuff->sdc_command, n);
+- swapl(&stuff->sdc_result_header, n);
++ _swaps(&stuff->length, n);
++ _swapl(&stuff->screen, n);
++ _swapl(&stuff->sdc_id, n);
++ _swapl(&stuff->sdc_command, n);
++ _swapl(&stuff->sdc_result_header, n);
+ for(i = 0; i < SDC_NUM_PARM_RESULT; i++) {
+- swapl(&stuff->sdc_parm[i], n);
+- swapl(&stuff->sdc_result[i], n);
++ _swapl(&stuff->sdc_parm[i], n);
++ _swapl(&stuff->sdc_result[i], n);
+ }
+ REQUEST_SIZE_MATCH(xSiSCtrlCommandReq);
+ return SiSUSBProcSiSCtrlCommand(client);
+@@ -911,7 +909,7 @@ SiSUSBCtrlResetProc(ExtensionEntry* extEntry)
+ {
+ /* Called by CloseDownExtensions() */
+ if(extEntry->extPrivate) {
+- xfree(extEntry->extPrivate);
++ free(extEntry->extPrivate);
+ extEntry->extPrivate = NULL;
+ }
+ }
+@@ -928,7 +926,7 @@ SiSUSBCtrlExtInit(ScrnInfoPtr pScrn)
+
+ if(!(myext = CheckExtension(SISCTRL_PROTOCOL_NAME))) {
+
+- if(!(myctrl = xcalloc(sizeof(xSiSCtrlScreenTable), 1)))
++ if(!(myctrl = calloc(sizeof(xSiSCtrlScreenTable), 1)))
+ return;
+
+ if(!(myext = AddExtension(SISCTRL_PROTOCOL_NAME, 0, 0,
+@@ -938,7 +936,7 @@ SiSUSBCtrlExtInit(ScrnInfoPtr pScrn)
+ StandardMinorOpcode))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to add SISCTRL extension\n");
+- xfree(myctrl);
++ free(myctrl);
+ return;
+ }
+
+diff --git a/src/sisusb_video.c b/src/sisusb_video.c
+index bc469b0..1dbf4f1 100644
+--- a/src/sisusb_video.c
++++ b/src/sisusb_video.c
+@@ -216,7 +216,7 @@ void SISUSBInitVideo(ScreenPtr pScreen)
+
+ if(newAdaptor) size++;
+
+- newAdaptors = xalloc(size * sizeof(XF86VideoAdaptorPtr*));
++ newAdaptors = malloc(size * sizeof(XF86VideoAdaptorPtr*));
+ if(newAdaptors) {
+ if(num_adaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr));
+@@ -234,7 +234,7 @@ void SISUSBInitVideo(ScreenPtr pScreen)
+ }
+
+ if(newAdaptors) {
+- xfree(newAdaptors);
++ free(newAdaptors);
+ }
+ }
+
+@@ -377,7 +377,7 @@ SISUSBSetupImageVideo(ScreenPtr pScreen)
+ XF86VideoAdaptorPtr adapt;
+ SISUSBPortPrivPtr pPriv;
+
+- if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
++ if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
+ sizeof(SISUSBPortPrivRec) +
+ sizeof(DevUnion))))
+ return NULL;
diff --git a/staging/xf86-video-tdfx/PKGBUILD b/staging/xf86-video-tdfx/PKGBUILD
new file mode 100644
index 000000000..e07fb4505
--- /dev/null
+++ b/staging/xf86-video-tdfx/PKGBUILD
@@ -0,0 +1,36 @@
+# $Id: PKGBUILD 149906 2012-02-11 15:05:23Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-tdfx
+pkgver=1.4.3
+pkgrel=8
+_gitver=a985b54c8559d7ff8f5481004d54989ed7499237
+pkgdesc="X.org tdfx video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libdrm' 'xf86driproto' 'mesa>=8.0') # 'glproto')
+conflicts=('xorg-server<1.11.99.902')
+options=(!libtool)
+groups=('xorg-drivers' 'xorg')
+source=(#${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ http://cgit.freedesktop.org/xorg/driver/xf86-video-tdfx/snapshot/xf86-video-tdfx-${_gitver}.tar.gz)
+sha1sums=('01c13cdec926c1aaa9c8c8855995c6cc38149ab2')
+
+build() {
+ #cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${srcdir}/${pkgname}*
+ autoreconf -fi
+ ./configure --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ #cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${srcdir}/${pkgname}*
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-trident/PKGBUILD b/staging/xf86-video-trident/PKGBUILD
new file mode 100644
index 000000000..f94206494
--- /dev/null
+++ b/staging/xf86-video-trident/PKGBUILD
@@ -0,0 +1,34 @@
+# $Id: PKGBUILD 149886 2012-02-11 11:56:00Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-trident
+pkgver=1.3.4
+pkgrel=6
+pkgdesc="X.org Trident video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86dgaproto')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=(!libtool)
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ trident-1.3.4-git.patch)
+sha1sums=('7c40f5c02bddf399862782b708941e79302318af'
+ 'cba17aad6cf2f051d89e65ffe26242ed62ea4454')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/trident-1.3.4-git.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-trident/trident-1.3.4-git.patch b/staging/xf86-video-trident/trident-1.3.4-git.patch
new file mode 100644
index 000000000..4e0cc27b2
--- /dev/null
+++ b/staging/xf86-video-trident/trident-1.3.4-git.patch
@@ -0,0 +1,523 @@
+diff --git a/configure.ac b/configure.ac
+index be54427..0fc2066 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,47 +20,47 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-trident],
+- 1.3.4,
++ [1.3.4],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-trident)
+-
++ [xf86-video-trident])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
++# Initialize Automake
+ AM_INIT_AUTOMAKE([foreign dist-bzip2])
+-
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_DEFAULT_OPTIONS
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+ m4_ifndef([XORG_MACROS_VERSION],
+- [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.3)
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
+ XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+ XORG_DRIVER_CHECK_EXT(XFreeXDGA, xf86dgaproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
+ PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+ HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
+@@ -90,17 +90,14 @@ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+ # Checks for libraries.
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=trident
+ AC_SUBST([DRIVER_NAME])
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 8f2454b..b3688ce 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -31,25 +31,11 @@ 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'
++
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
++
+
+ SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+ .man.$(DRIVER_MAN_SUFFIX):
+- sed $(MAN_SUBSTS) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/trident.man b/man/trident.man
+index 8d04ed0..f461e10 100644
+--- a/man/trident.man
++++ b/man/trident.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.man,v 1.14 2003/05/29 21:48:09 herrb Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH TRIDENT __drivermansuffix__ __vendorversion__
+diff --git a/src/blade_accel_exa.c b/src/blade_accel_exa.c
+index 80e3f23..3129623 100644
+--- a/src/blade_accel_exa.c
++++ b/src/blade_accel_exa.c
+@@ -251,14 +251,6 @@ static void WaitMarker(ScreenPtr pScreen, int marker)
+ }
+ }
+
+-static Bool PrepareAccess(PixmapPtr pPix, int index)
+-{
+-}
+-
+-static void FinishAccess(PixmapPtr pPix, int index)
+-{
+-}
+-
+ static void BladeInitializeAccelerator(ScrnInfoPtr pScrn)
+ {
+ TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+diff --git a/src/trident.h b/src/trident.h
+index c15d39c..a28c9fc 100644
+--- a/src/trident.h
++++ b/src/trident.h
+@@ -70,7 +70,7 @@ typedef struct {
+ typedef struct {
+ ScrnInfoPtr pScrn;
+ pciVideoPtr PciInfo;
+- PCITAG PciTag;
++ uint32_t PciTag;
+ EntityInfoPtr pEnt;
+ ExaDriverPtr EXADriverPtr;
+ int useEXA;
+@@ -85,7 +85,7 @@ typedef struct {
+ unsigned char * IOBase;
+ unsigned char * FbBase;
+ long FbMapSize;
+- IOADDRESS PIOBase;
++ unsigned long PIOBase;
+ Bool NoAccel;
+ Bool HWCursor;
+ Bool UsePCIRetry;
+diff --git a/src/trident_dga.c b/src/trident_dga.c
+index 78fa8f4..dd836a6 100644
+--- a/src/trident_dga.c
++++ b/src/trident_dga.c
+@@ -83,15 +83,15 @@ TRIDENTDGAInit(ScreenPtr pScreen)
+ while(pMode) {
+
+ if(0 /*pScrn->displayWidth != pMode->HDisplay*/) {
+- newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
++ newmodes = realloc(modes, (num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+- newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
++ newmodes = realloc(modes, (num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+- xfree(modes);
++ free(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+diff --git a/src/trident_driver.c b/src/trident_driver.c
+index 31cbb83..472c9b7 100644
+--- a/src/trident_driver.c
++++ b/src/trident_driver.c
+@@ -63,7 +63,7 @@
+
+ #ifdef XFreeXDGA
+ #define _XF86DGA_SERVER_
+-#include <X11/extensions/xf86dgastr.h>
++#include <X11/extensions/xf86dgaproto.h>
+ #endif
+
+ #include "globals.h"
+@@ -560,7 +560,7 @@ TRIDENTFreeRec(ScrnInfoPtr pScrn)
+ {
+ if (pScrn->driverPrivate == NULL)
+ return;
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -900,7 +900,7 @@ TRIDENTProbe(DriverPtr drv, int flags)
+ foundScreen = TRUE;
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+ }
+ }
+
+@@ -933,11 +933,11 @@ TRIDENTProbe(DriverPtr drv, int flags)
+ foundScreen = TRUE;
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+ }
+ #endif
+
+- xfree(devSections);
++ free(devSections);
+ return foundScreen;
+ }
+
+@@ -1109,7 +1109,12 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
+ hwp = VGAHWPTR(pScrn);
+ vgaHWGetIOBase(hwp);
+ vgaIOBase = hwp->IOBase;
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ pTrident->PIOBase = hwp->PIOOffset;
++#else
++ pTrident->PIOBase = 0;
++#endif
+
+ #ifndef XSERVER_LIBPCIACCESS
+ xf86SetOperatingState(resVga, pTrident->pEnt->index, ResUnusedOpr);
+@@ -1163,7 +1168,7 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if (!(pTrident->Options = xalloc(sizeof(TRIDENTOptions))))
++ if (!(pTrident->Options = malloc(sizeof(TRIDENTOptions))))
+ return FALSE;
+ memcpy(pTrident->Options, TRIDENTOptions, sizeof(TRIDENTOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pTrident->Options);
+@@ -2617,7 +2622,10 @@ TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+ TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ TRIDENTRegPtr tridentReg;
+
+- if (!xf86IsPc98()) WAITFORVSYNC;
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (!xf86IsPc98())
++#endif
++ WAITFORVSYNC;
+
+ TridentFindClock(pScrn,mode->Clock);
+
+@@ -2709,8 +2717,10 @@ TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+
+ vgaHWProtect(pScrn, FALSE);
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ if (xf86IsPc98())
+ PC98TRIDENTEnable(pScrn);
++#endif
+
+ if (pTrident->TVChipset != 0)
+ VIA_TVInit(pScrn);
+@@ -2782,7 +2792,10 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ if (!TRIDENTMapMem(pScrn))
+ return FALSE;
+
+- if (!xf86IsPc98()) {
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (!xf86IsPc98())
++#endif
++ {
+ #ifdef VBE_INFO
+ if (pTrident->vbeModes) {
+ pTrident->pVbe = VBEInit(NULL,pTrident->pEnt->index);
+@@ -2796,7 +2809,7 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ }
+ }
+ }
+-
++
+ hwp = VGAHWPTR(pScrn);
+
+ if (IsPciCard && UseMMIO) {
+@@ -2813,9 +2826,12 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ * Some Trident chip on PC-9821 needs setup,
+ * because VGA chip is not initialized by VGA BIOS.
+ */
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ if (IsPciCard && xf86IsPc98()) {
+ PC98TRIDENTInit(pScrn);
+- } else tridentSetModeBIOS(pScrn,pScrn->currentMode);
++ } else
++#endif
++ tridentSetModeBIOS(pScrn,pScrn->currentMode);
+
+ /* Initialise the first mode */
+ if (!TRIDENTModeInit(pScrn, pScrn->currentMode))
+@@ -2868,7 +2884,7 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+
+ if(pTrident->ShadowFB) {
+ pTrident->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
+- pTrident->ShadowPtr = xalloc(pTrident->ShadowPitch * height);
++ pTrident->ShadowPtr = malloc(pTrident->ShadowPitch * height);
+ displayWidth = pTrident->ShadowPitch / (pScrn->bitsPerPixel >> 3);
+ FBStart = pTrident->ShadowPtr;
+ } else {
+@@ -2958,7 +2974,7 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ (miBankProcPtr)TVGA8900SetReadWrite;
+ if (!miInitializeBanking(pScreen, pScrn->virtualX, pScrn->virtualY,
+ pScrn->displayWidth, pBankInfo)) {
+- xfree(pBankInfo);
++ free(pBankInfo);
+ pBankInfo = NULL;
+ if (pTrident->pVbe)
+ vbeFree(pTrident->pVbe);
+@@ -3200,8 +3216,10 @@ TRIDENTLeaveVT(int scrnIndex, int flags)
+ TRIDENTRestore(pScrn);
+ vgaHWLock(hwp);
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ if (xf86IsPc98())
+ PC98TRIDENTDisable(pScrn);
++#endif
+
+ if (IsPciCard && UseMMIO) TRIDENTDisableMMIO(pScrn);
+ }
+@@ -3225,28 +3243,31 @@ TRIDENTCloseScreen(int scrnIndex, ScreenPtr pScreen)
+ pTrident->AccelInfoRec->Sync(pScrn);
+ else if (!pTrident->NoAccel && pTrident->useEXA)
+ pTrident->EXADriverPtr->WaitMarker(pScreen, 0);
+-
++
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ if (xf86IsPc98())
+ PC98TRIDENTDisable(pScrn);
++#endif
+
+ TRIDENTRestore(pScrn);
+ vgaHWLock(hwp);
+ if (IsPciCard && UseMMIO) TRIDENTDisableMMIO(pScrn);
+ TRIDENTUnmapMem(pScrn);
+ }
++
+ if (pTrident->AccelInfoRec)
+ XAADestroyInfoRec(pTrident->AccelInfoRec);
+ if (pTrident->EXADriverPtr) {
+ exaDriverFini(pScreen);
+- xfree(pTrident->EXADriverPtr);
++ free(pTrident->EXADriverPtr);
+ pTrident->EXADriverPtr = NULL;
+ }
+ if (pTrident->CursorInfoRec)
+ xf86DestroyCursorInfoRec(pTrident->CursorInfoRec);
+ if (pTrident->ShadowPtr)
+- xfree(pTrident->ShadowPtr);
++ free(pTrident->ShadowPtr);
+ if (pTrident->DGAModes)
+- xfree(pTrident->DGAModes);
++ free(pTrident->DGAModes);
+ pScrn->vtSema = FALSE;
+
+ if(pTrident->BlockHandler)
+@@ -3317,15 +3338,17 @@ static void
+ TRIDENTEnableMMIO(ScrnInfoPtr pScrn)
+ {
+ TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+- IOADDRESS vgaIOBase = pTrident->PIOBase + VGAHWPTR(pScrn)->IOBase;
++ unsigned long vgaIOBase = pTrident->PIOBase + VGAHWPTR(pScrn)->IOBase;
+ CARD8 temp = 0, protect = 0;
+
+ /*
+ * Skip MMIO Enable in PC-9821 PCI Trident Card!!
+ * Because of lack of non PCI VGA port
+ */
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ if (IsPciCard && xf86IsPc98())
+ return;
++#endif
+
+ /* Goto New Mode */
+ outb(pTrident->PIOBase + 0x3C4, 0x0B);
+@@ -3366,8 +3389,10 @@ TRIDENTDisableMMIO(ScrnInfoPtr pScrn)
+ * Skip MMIO Disable in PC-9821 PCI Trident Card!!
+ * Because of lack of non PCI VGA port
+ */
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ if (IsPciCard && xf86IsPc98())
+ return;
++#endif
+
+ /* Goto New Mode */
+ OUTB(0x3C4, 0x0B); temp = INB(0x3C5);
+@@ -3395,6 +3420,7 @@ TRIDENTDisableMMIO(ScrnInfoPtr pScrn)
+ outb(pTrident->PIOBase + 0x3C5, temp);
+ }
+
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ /* Initialize VGA Block for Trident Chip on PC-98x1 */
+ static void
+ PC98TRIDENTInit(ScrnInfoPtr pScrn)
+@@ -3637,7 +3663,7 @@ PC98TRIDENT96xxDisable(ScrnInfoPtr pScrn)
+ outb(0x6A, 0x06);
+ outb(0x68, 0x0F);
+ }
+-
++#endif
+
+ /*
+ * This is a terrible hack! If we are on a notebook in a stretched
+diff --git a/src/trident_video.c b/src/trident_video.c
+index 0c5497b..0ae1d14 100644
+--- a/src/trident_video.c
++++ b/src/trident_video.c
+@@ -125,7 +125,7 @@ void TRIDENTInitVideo(ScreenPtr pScreen)
+ adaptors = &newAdaptor;
+ } else {
+ newAdaptors = /* need to free this someplace */
+- xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
++ malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
+ if(newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(XF86VideoAdaptorPtr));
+@@ -140,7 +140,7 @@ void TRIDENTInitVideo(ScreenPtr pScreen)
+ xf86XVScreenInit(pScreen, adaptors, num_adaptors);
+
+ if(newAdaptors)
+- xfree(newAdaptors);
++ free(newAdaptors);
+
+ if (pTrident->videoFlags)
+ xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,3,
+@@ -321,7 +321,7 @@ TRIDENTSetupImageVideo(ScreenPtr pScreen)
+ XF86VideoAdaptorPtr adapt;
+ TRIDENTPortPrivPtr pPriv;
+
+- if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
++ if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
+ sizeof(TRIDENTPortPrivRec) +
+ sizeof(DevUnion))))
+ return NULL;
+@@ -978,18 +978,18 @@ TRIDENTAllocateSurface(
+ surface->width = w;
+ surface->height = h;
+
+- if(!(surface->pitches = xalloc(sizeof(int)))) {
++ if(!(surface->pitches = malloc(sizeof(int)))) {
+ xf86FreeOffscreenLinear(linear);
+ return BadAlloc;
+ }
+- if(!(surface->offsets = xalloc(sizeof(int)))) {
+- xfree(surface->pitches);
++ if(!(surface->offsets = malloc(sizeof(int)))) {
++ free(surface->pitches);
+ xf86FreeOffscreenLinear(linear);
+ return BadAlloc;
+ }
+- if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
+- xfree(surface->pitches);
+- xfree(surface->offsets);
++ if(!(pPriv = malloc(sizeof(OffscreenPrivRec)))) {
++ free(surface->pitches);
++ free(surface->offsets);
+ xf86FreeOffscreenLinear(linear);
+ return BadAlloc;
+ }
+@@ -1034,9 +1034,9 @@ TRIDENTFreeSurface(
+ if(pPriv->isOn)
+ TRIDENTStopSurface(surface);
+ xf86FreeOffscreenLinear(pPriv->linear);
+- xfree(surface->pitches);
+- xfree(surface->offsets);
+- xfree(surface->devPrivate.ptr);
++ free(surface->pitches);
++ free(surface->offsets);
++ free(surface->devPrivate.ptr);
+
+ return Success;
+ }
+@@ -1128,7 +1128,7 @@ TRIDENTInitOffscreenImages(ScreenPtr pScreen)
+ XF86OffscreenImagePtr offscreenImages;
+
+ /* need to free this someplace */
+- if(!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
++ if(!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec))))
+ return;
+
+ offscreenImages[0].image = &Images[0];
+@@ -1342,7 +1342,10 @@ WaitForVBlank(ScrnInfoPtr pScrn)
+ * full vblank has passed.
+ * - Alan.
+ */
+- if (!xf86IsPc98()) {
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ if (!xf86IsPc98())
++#endif
++ {
+ WAITFORVSYNC;
+ WAITFORVSYNC;
+ }
diff --git a/staging/xf86-video-tseng/PKGBUILD b/staging/xf86-video-tseng/PKGBUILD
new file mode 100644
index 000000000..411415341
--- /dev/null
+++ b/staging/xf86-video-tseng/PKGBUILD
@@ -0,0 +1,33 @@
+# $Id: PKGBUILD 149888 2012-02-11 11:59:32Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-tseng
+pkgver=1.2.4
+pkgrel=6
+pkgdesc="X.org tseng video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ tseng-1.2.4-git.patch)
+sha1sums=('1b45f55657b2c92f30abb0769cae57fca98d93b7'
+ 'd84bb75d62888096da7477b38e8b13f9c23d4e3a')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i ${srcdir}/tseng-1.2.4-git.patch
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-tseng/tseng-1.2.4-git.patch b/staging/xf86-video-tseng/tseng-1.2.4-git.patch
new file mode 100644
index 000000000..082b2cb0b
--- /dev/null
+++ b/staging/xf86-video-tseng/tseng-1.2.4-git.patch
@@ -0,0 +1,317 @@
+diff --git a/configure.ac b/configure.ac
+index 62cc318..8458c06 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,46 +20,46 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-tseng],
+- 1.2.4,
++ [1.2.4],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-tseng)
+-
++ [xf86-video-tseng])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
++# Initialize Automake
+ AM_INIT_AUTOMAKE([foreign dist-bzip2])
+-
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_DEFAULT_OPTIONS
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+ m4_ifndef([XORG_MACROS_VERSION],
+- [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.3)
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
+ XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
+
+ # Checks for libraries.
+@@ -78,17 +78,14 @@ if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=tseng
+ AC_SUBST([DRIVER_NAME])
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index 8f2454b..b3688ce 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -31,25 +31,11 @@ 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'
++
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
++
+
+ SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+ .man.$(DRIVER_MAN_SUFFIX):
+- sed $(MAN_SUBSTS) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/tseng.man b/man/tseng.man
+index 403782f..984c8e7 100644
+--- a/man/tseng.man
++++ b/man/tseng.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.man,v 1.2 2001/01/27 18:20:55 dawes Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH TSENG __drivermansuffix__ __vendorversion__
+diff --git a/src/tseng_cursor.c b/src/tseng_cursor.c
+index d4fb847..2412b31 100644
+--- a/src/tseng_cursor.c
++++ b/src/tseng_cursor.c
+@@ -159,7 +159,7 @@ TsengSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+ }
+ }
+
+-void
++static void
+ TsengLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits)
+ {
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+diff --git a/src/tseng_dga.c b/src/tseng_dga.c
+index 70ebe23..528ba4c 100644
+--- a/src/tseng_dga.c
++++ b/src/tseng_dga.c
+@@ -74,9 +74,9 @@ TsengDGAInit(ScreenPtr pScreen)
+ if (!pTseng->DGAnumModes) {
+ pMode = firstMode = pScrn->modes;
+ while (pMode) {
+- newmodes = xrealloc(modes, (num + 1) * sizeof (DGAModeRec));
++ newmodes = realloc(modes, (num + 1) * sizeof (DGAModeRec));
+ if (!newmodes) {
+- xfree(modes);
++ free(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+@@ -135,7 +135,7 @@ Tseng_OpenFramebuffer(
+ TsengPtr pTseng = TsengPTR(pScrn);
+
+ *name = NULL; /* no special device */
+- *mem = (unsigned char*)pTseng->FbAddress;
++ *mem = (unsigned char*)(uintptr_t)pTseng->FbAddress;
+ *size = pTseng->FbMapSize;
+ *offset = 0; /* Always */
+ *flags = 0; /* Root permissions OS-dependent */
+diff --git a/src/tseng_driver.c b/src/tseng_driver.c
+index 445c17e..d36b62c 100644
+--- a/src/tseng_driver.c
++++ b/src/tseng_driver.c
+@@ -269,9 +269,9 @@ TsengFreeRec(ScrnInfoPtr pScrn)
+ pTseng = TsengPTR(pScrn);
+
+ if (pTseng->SavedReg.RAMDAC)
+- xfree(pTseng->SavedReg.RAMDAC);
++ free(pTseng->SavedReg.RAMDAC);
+
+- xfree(pScrn->driverPrivate);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -395,10 +395,10 @@ TsengProbe(DriverPtr drv, int flags)
+ foundScreen = TRUE;
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+ }
+
+- xfree(devSections);
++ free(devSections);
+ return foundScreen;
+ }
+
+@@ -806,7 +806,7 @@ TsengProcessOptions(ScrnInfoPtr pScrn)
+ xf86CollectOptions(pScrn, NULL);
+
+ /* Process the options */
+- if (!(pTseng->Options = xalloc(sizeof(TsengOptions))))
++ if (!(pTseng->Options = malloc(sizeof(TsengOptions))))
+ return FALSE;
+ memcpy(pTseng->Options, TsengOptions, sizeof(TsengOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pTseng->Options);
+@@ -883,7 +883,7 @@ TsengGetFbAddress(ScrnInfoPtr pScrn)
+ PDEBUG(" TsengGetFbAddress\n");
+
+ /* base0 is the framebuffer and base1 is the PCI IO space. */
+- if (PCI_REGION_BASE(pTseng->PciInfo, 0, REGION_MEM)) {
++ if (!PCI_REGION_BASE(pTseng->PciInfo, 0, REGION_MEM)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "No valid Framebuffer address in PCI config space;\n");
+ return FALSE;
+diff --git a/src/tseng_mode.c b/src/tseng_mode.c
+index f075226..a3ff87d 100644
+--- a/src/tseng_mode.c
++++ b/src/tseng_mode.c
+@@ -41,7 +41,11 @@ vgaHWWriteBank(vgaHWPtr hwp, CARD8 value)
+ if (hwp->MMIOBase)
+ MMIO_OUT8(hwp->MMIOBase, hwp->MMIOOffset + VGA_BANK, value);
+ else
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ outb(hwp->PIOOffset + VGA_BANK, value);
++#else
++ pci_io_write8(hwp->io, VGA_BANK, value);
++#endif
+ }
+
+ CARD8
+@@ -50,7 +54,11 @@ vgaHWReadBank(vgaHWPtr hwp)
+ if (hwp->MMIOBase)
+ return MMIO_IN8(hwp->MMIOBase, hwp->MMIOOffset + VGA_BANK);
+ else
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ return inb(hwp->PIOOffset + VGA_BANK);
++#else
++ return pci_io_read8(hwp->io, VGA_BANK);
++#endif
+ }
+
+ #define VGA_SEGMENT 0x3CD
+@@ -61,7 +69,11 @@ vgaHWWriteSegment(vgaHWPtr hwp, CARD8 value)
+ if (hwp->MMIOBase)
+ MMIO_OUT8(hwp->MMIOBase, hwp->MMIOOffset + VGA_SEGMENT, value);
+ else
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ outb(hwp->PIOOffset + VGA_SEGMENT, value);
++#else
++ pci_io_write8(hwp->io, VGA_SEGMENT, value);
++#endif
+ }
+
+ CARD8
+@@ -70,7 +82,11 @@ vgaHWReadSegment(vgaHWPtr hwp)
+ if (hwp->MMIOBase)
+ return MMIO_IN8(hwp->MMIOBase, hwp->MMIOOffset + VGA_SEGMENT);
+ else
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
+ return inb(hwp->PIOOffset + VGA_SEGMENT);
++#else
++ return pci_io_read8(hwp->io, VGA_SEGMENT);
++#endif
+ }
+
+ /*
+@@ -84,8 +100,12 @@ vgaHWWriteModeControl(vgaHWPtr hwp, CARD8 value)
+ if (hwp->MMIOBase)
+ MMIO_OUT8(hwp->MMIOBase,
+ hwp->MMIOOffset + hwp->IOBase + VGA_MODE_CONTROL, value);
+- else
+- outb(hwp->IOBase + hwp->PIOOffset + VGA_MODE_CONTROL, value);
++ else
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ outb(hwp->PIOOffset + VGA_MODE_CONTROL, value);
++#else
++ pci_io_write8(hwp->io, VGA_MODE_CONTROL, value);
++#endif
+ }
+
+ /*
+@@ -110,14 +130,22 @@ vgaHWHerculesSecondPage(vgaHWPtr hwp, Bool Enable)
+
+ MMIO_OUT8(hwp->MMIOBase, hwp->MMIOOffset + VGA_HERCULES, tmp);
+ } else {
+- tmp = inb(hwp->PIOOffset + VGA_HERCULES);
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ tmp = inb(hwp->PIOOffset + VGA_HERCULES);
++#else
++ tmp = pci_io_read8(hwp->io, VGA_HERCULES);
++#endif
+
+ if (Enable)
+ tmp |= 0x02;
+ else
+ tmp &= ~0x02;
+
+- outb(hwp->PIOOffset + VGA_HERCULES, tmp);
++#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
++ outb(hwp->PIOOffset + VGA_HERCULES, tmp);
++#else
++ pci_io_write8(hwp->io, VGA_HERCULES, tmp);
++#endif
+ }
+ }
+
+@@ -1502,7 +1530,7 @@ TsengModeInit(ScrnInfoPtr pScrn, DisplayModePtr OrigMode)
+
+ /* clean up */
+ if (new->RAMDAC)
+- xfree(new->RAMDAC);
++ free(new->RAMDAC);
+
+ return TRUE;
+ }
diff --git a/staging/xf86-video-unichrome/LICENSE b/staging/xf86-video-unichrome/LICENSE
new file mode 100644
index 000000000..f4007667b
--- /dev/null
+++ b/staging/xf86-video-unichrome/LICENSE
@@ -0,0 +1,23 @@
+Copyright (c) 2004-2007 Luc Verhaegen. All Rights Reserved.
+Copyright (c) 2004-2005 The Unichrome Project. All Rights Reserved.
+Copyright (c) 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+Copyright (c) 2001-2003 S3 Graphics, Inc. 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, 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
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/staging/xf86-video-unichrome/PKGBUILD b/staging/xf86-video-unichrome/PKGBUILD
new file mode 100644
index 000000000..05903b22a
--- /dev/null
+++ b/staging/xf86-video-unichrome/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149894 2012-02-11 12:05:14Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-unichrome
+pkgver=0.2.7
+pkgrel=7
+_gitversion=b917bee87db8a65b8e8da0ca12c24a176c9e9fb2
+pkgdesc="Unichrome video drivers for X.Org"
+arch=(i686 x86_64)
+url="http://unichrome.sf.net/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libx11' 'libdrm' 'xf86driproto' 'mesa' 'libxvmc') # 'glproto')
+options=('!libtool')
+conflicts=('xf86-video-via' 'openchrome' 'xf86-video-openchrome' 'xorg-server<1.11.99.903')
+source=(http://cgit.freedesktop.org/~libv/${pkgname}/snapshot/${pkgname}-${_gitversion}.tar.bz2)
+md5sums=('f7adef052de08a01af86e245d1932239')
+
+build() {
+ cd "${srcdir}/${pkgname}-${_gitversion}"
+ ./autogen.sh --prefix=/usr #--enable-dri
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${_gitversion}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 debian/copyright "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
+}
diff --git a/staging/xf86-video-v4l/LICENSE b/staging/xf86-video-v4l/LICENSE
new file mode 100644
index 000000000..535595b88
--- /dev/null
+++ b/staging/xf86-video-v4l/LICENSE
@@ -0,0 +1,826 @@
+This package was downloaded from
+http://xorg.freedesktop.org/releases/individual/driver/
+
+ Licenses
+
+ The X.Org Foundation
+
+ March 2004
+
+1. Introduction
+
+The X.org Foundation X Window System distribution is a compilation of code
+and documentation from many sources. This document is intended primarily as
+a guide to the licenses used in the distribution: you must check each file
+and/or package for precise redistribution terms. None-the-less, this summary
+may be useful to many users. No software incorporating the XFree86 1.1
+license has been incorporated.
+
+This document is based on the compilation from XFree86.
+
+2. XFree86 License
+
+XFree86 code without an explicit copyright is covered by the following copy-
+right/license:
+
+Copyright (C) 1994-2003 The XFree86 Project, Inc. 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.
+
+Except as contained in this notice, the name of the XFree86 Project shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from the XFree86
+Project.
+
+3. Other Licenses
+
+Portions of code are covered by the following licenses/copyrights. See indi-
+vidual files for the copyright dates.
+
+3.1 X/MIT Copyrights
+
+3.1.1 X Consortium
+
+Copyright (C) <date> X Consortium
+
+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 X
+CONSORTIUM 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 X Consortium 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 X Consortium.
+
+X Window System is a trademark of X Consortium, Inc.
+
+3.1.2 The Open Group
+
+Copyright <date> The Open Group
+
+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, FIT-
+NESS 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 Open Group 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 Open Group.
+
+3.2 Berkeley-based copyrights:
+
+o
+
+3.2.1 General
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+3.2.2 UCB/LBL
+
+Copyright (c) 1993 The Regents of the University of California. All rights
+reserved.
+
+This software was developed by the Computer Systems Engineering group at
+Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and contributed to
+Berkeley.
+
+All advertising materials mentioning features or use of this software must
+display the following acknowledgement: This product includes software devel-
+oped by the University of California, Lawrence Berkeley Laboratory.
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. All advertising materials mentioning features or use of this software
+ must display the following acknowledgement: This product includes soft-
+ ware developed by the University of California, Berkeley and its con-
+ tributors.
+
+ 4. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
+CLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+3.2.3 The NetBSD Foundation, Inc.
+
+Copyright (c) 2003 The NetBSD Foundation, Inc. All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation by
+Ben Collver <collver1@attbi.com>
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. All advertising materials mentioning features or use of this software
+ must display the following acknowledgement: This product includes soft-
+ ware developed by the NetBSD Foundation, Inc. and its contributors.
+
+ 4. Neither the name of The NetBSD Foundation nor the names of its con-
+ tributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSE-
+QUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAM-
+AGE.
+
+3.2.4 Theodore Ts'o.
+
+Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999. All rights
+reserved.
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ and the entire permission notice in its entirety, including the dis-
+ claimer of warranties.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. he name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH ARE HEREBY DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF NOT
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+3.2.5 Theo de Raadt and Damien Miller
+
+Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. Copyright (c)
+2001-2002 Damien Miller. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+3.2.6 Todd C. Miller
+
+Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+
+Permission to use, copy, modify, and distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright
+notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MER-
+CHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE FOR ANY
+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CON-
+TRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+3.2.7 Thomas Winischhofer
+
+Copyright (C) 2001-2004 Thomas Winischhofer
+
+Redistribution and use in source and binary forms, with or without modifica-
+tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+3.3 NVIDIA Corp
+
+Copyright (c) 1996 NVIDIA, Corp. All rights reserved.
+
+NOTICE TO USER: The source code is copyrighted under U.S. and international
+laws. NVIDIA, Corp. of Sunnyvale, California owns the copyright and as
+design patents pending on the design and interface of the NV chips. Users
+and possessors of this source code are hereby granted a nonexclusive, roy-
+alty-free copyright and design patent license to use this code in individual
+and commercial software.
+
+Any use of this source code must include, in the user documentation and
+internal comments to the code, notices to the end user as follows:
+
+Copyright (c) 1996 NVIDIA, Corp. NVIDIA design patents pending in the U.S.
+and foreign countries.
+
+NVIDIA, CORP. MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
+CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WAR-
+RANTY OF ANY KIND. NVIDIA, CORP. DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA, CORP. BE LIABLE
+FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAM-
+AGES 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 SOURCE CODE.
+
+3.4 GLX Public License
+
+GLX PUBLIC LICENSE (Version 1.0 (2/11/99)) ("License")
+
+Subject to any third party claims, Silicon Graphics, Inc. ("SGI") hereby
+grants permission to Recipient (defined below), under Recipient's copyrights
+in the Original Software (defined below), to use, copy, modify, merge, pub-
+lish, distribute, sublicense and/or sell copies of Subject Software (defined
+below), and to permit persons to whom the Subject Software is furnished in
+accordance with this License to do the same, subject to all of the following
+terms and conditions, which Recipient accepts by engaging in any such use,
+copying, modifying, merging, publishing, distributing, sublicensing or sell-
+ing:
+
+1. Definitions.
+
+ (a) "Original Software" means source code of computer software code
+ which is described in Exhibit A as Original Software.
+
+ (b) "Modifications" means any addition to or deletion from the sub-
+ stance or structure of either the Original Software or any previous
+ Modifications. When Subject Software is released as a series of
+ files, a Modification means (i) any addition to or deletion from
+ the contents of a file containing Original Software or previous
+ Modifications and (ii) any new file that contains any part of the
+ Original Code or previous Modifications.
+
+ (c) "Subject Software" means the Original Software or Modifications
+ or the combination of the Original Software and Modifications, or
+ portions of any of the foregoing.
+
+ (d) "Recipient" means an individual or a legal entity exercising
+ rights under, and complying with all of the terms of, this License.
+ For legal entities, "Recipient" includes any entity which controls,
+ is controlled by, or is under common control with Recipient. For
+ purposes of this definition, "control" of an entity means (a) the
+ power, direct or indirect, to direct or manage such entity, or (b)
+ ownership of fifty percent (50%) or more of the outstanding shares
+ or beneficial ownership of such entity.
+
+2. Redistribution of Source Code Subject to These Terms. Redistributions of
+Subject Software in source code form must retain the notice set forth in
+Exhibit A, below, in every file. A copy of this License must be included in
+any documentation for such Subject Software where the recipients' rights
+relating to Subject Software are described. Recipient may distribute the
+source code version of Subject Software under a license of Recipient's
+choice, which may contain terms different from this License, provided that
+(i) Recipient is in compliance with the terms of this License, and (ii) the
+license terms include this Section 2 and Sections 3, 4, 7, 8, 10, 12 and 13
+of this License, which terms may not be modified or superseded by any other
+terms of such license. If Recipient distributes the source code version under
+a different license Recipient must make it absolutely clear that any terms
+which differ from this License are offered by Recipient alone, not by SGI.
+Recipient hereby agrees to indemnify SGI for any liability incurred by SGI as
+a result of any such terms Recipient offers.
+
+3. Redistribution in Executable Form. The notice set forth in Exhibit A must
+be conspicuously included in any notice in an executable version of Subject
+Software, related documentation or collateral in which Recipient describes
+the user's rights relating to the Subject Software. Recipient may distribute
+the executable version of Subject Software under a license of Recipient's
+choice, which may contain terms different from this License, provided that
+(i) Recipient is in compliance with the terms of this License, and (ii) the
+license terms include this Section 3 and Sections 4, 7, 8, 10, 12 and 13 of
+this License, which terms may not be modified or superseded by any other
+terms of such license. If Recipient distributes the executable version under
+a different license Recipient must make it absolutely clear that any terms
+which differ from this License are offered by Recipient alone, not by SGI.
+Recipient hereby agrees to indemnify SGI for any liability incurred by SGI as
+a result of any such terms Recipient offers.
+
+4. Termination. This License and the rights granted hereunder will terminate
+automatically if Recipient fails to comply with terms herein and fails to
+cure such breach within 30 days of the breach. Any sublicense to the Subject
+Software which is properly granted shall survive any termination of this
+License absent termination by the terms of such sublicense. Provisions which,
+by their nature, must remain in effect beyond the termination of this License
+shall survive.
+
+5. No Trademark Rights. This License does not grant any rights to use any
+trade name, trademark or service mark whatsoever. No trade name, trademark or
+service mark of SGI may be used to endorse or promote products derived from
+the Subject Software without prior written permission of SGI.
+
+6. No Other Rights. This License does not grant any rights with respect to
+the OpenGL API or to any software or hardware implementation thereof or to
+any other software whatsoever, nor shall any other rights or licenses not
+expressly granted hereunder arise by implication, estoppel or otherwise with
+respect to the Subject Software. Title to and ownership of the Original Soft-
+ware at all times remains with SGI. All rights in the Original Software not
+expressly granted under this License are reserved.
+
+7. Compliance with Laws; Non-Infringement. Recipient shall comply with all
+applicable laws and regulations in connection with use and distribution of
+the Subject Software, including but not limited to, all export and import
+control laws and regulations of the U.S. government and other countries.
+Recipient may not distribute Subject Software that (i) in any way infringes
+(directly or contributorily) the rights (including patent, copyright, trade
+secret, trademark or other intellectual property rights of any kind) of any
+other person or entity or (ii) breaches any representation or warranty,
+express, implied or statutory, which under any applicable law it might be
+deemed to have been distributed.
+
+8. Claims of Infringement. If Recipient at any time has knowledge of any one
+or more third party claims that reproduction, modification, use, distribu-
+tion, import or sale of Subject Software (including particular functionality
+or code incorporated in Subject Software) infringes the third party's intel-
+lectual property rights, Recipient must place in a well-identified web page
+bearing the title "LEGAL" a description of each such claim and a description
+of the party making each such claim in sufficient detail that a user of the
+Subject Software will know whom to contact regarding the claim. Also, upon
+gaining such knowledge of any such claim, Recipient must conspicuously
+include the URL for such web page in the Exhibit A notice required under Sec-
+tions 2 and 3, above, and in the text of any related documentation, license
+agreement or collateral in which Recipient describes end user's rights relat-
+ing to the Subject Software. If Recipient obtains such knowledge after it
+makes Subject Software available to any other person or entity, Recipient
+shall take other steps (such as notifying appropriate mailing lists or news-
+groups) reasonably calculated to inform those who received the Subject Soft-
+ware that new knowledge has been obtained.
+
+9. DISCLAIMER OF WARRANTY. SUBJECT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE SUBJECT SOFTWARE IS FREE OF DEFECTS, MER-
+CHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON- INFRINGING. SGI ASSUMES NO
+RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. SHOULD ANY SOFTWARE
+PROVE DEFECTIVE IN ANY RESPECT, SGI ASSUMES NO COST OR LIABILITY FOR ANY SER-
+VICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN
+ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY SUBJECT SOFTWARE IS AUTHORIZED
+HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+10. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THE-
+ORY, WHETHER TORT (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE OR STRICT LIA-
+BILITY), CONTRACT, OR OTHERWISE, SHALL SGI OR ANY SGI LICENSOR BE LIABLE FOR
+ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK
+STOPPAGE, LOSS OF DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF
+THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY
+TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SGI's NEGLIGENCE TO
+THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES,
+SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO RECIPIENT.
+
+11. Indemnity. Recipient shall be solely responsible for damages arising,
+directly or indirectly, out of its utilization of rights under this License.
+Recipient will defend, indemnify and hold harmless Silicon Graphics, Inc.
+from and against any loss, liability, damages, costs or expenses (including
+the payment of reasonable attorneys fees) arising out of Recipient's use,
+modification, reproduction and distribution of the Subject Software or out of
+any representation or warranty made by Recipient.
+
+12. U.S. Government End Users. The Subject Software is a "commercial item"
+consisting of "commercial computer software" as such terms are defined in
+title 48 of the Code of Federal Regulations and all U.S. Government End
+Users acquire only the rights set forth in this License and are subject to
+the terms of this License.
+
+13. Miscellaneous. This License represents the complete agreement concerning
+subject matter hereof. If any provision of this License is held to be unen-
+forceable, such provision shall be reformed so as to achieve as nearly as
+possible the same economic effect as the original provision and the remainder
+of this License will remain in effect. This License shall be governed by and
+construed in accordance with the laws of the United States and the State of
+California as applied to agreements entered into and to be performed entirely
+within California between California residents. Any litigation relating to
+this License shall be subject to the exclusive jurisdiction of the Federal
+Courts of the Northern District of California (or, absent subject matter
+jurisdiction in such courts, the courts of the State of California), with
+venue lying exclusively in Santa Clara County, California, with the losing
+party responsible for costs, including without limitation, court costs and
+reasonable attorneys fees and expenses. The application of the United Nations
+Convention on Contracts for the International Sale of Goods is expressly
+excluded. Any law or regulation which provides that the language of a con-
+tract shall be construed against the drafter shall not apply to this License.
+
+Exhibit A
+
+The contents of this file are subject to Sections 2, 3, 4, 7, 8, 10, 12 and
+13 of the GLX Public License Version 1.0 (the "License"). You may not use
+this file except in compliance with those sections of the License. You may
+obtain a copy of the License at Silicon Graphics, Inc., attn: Legal Services,
+2011 N. Shoreline Blvd., Mountain View, CA 94043 or at
+http://www.sgi.com/software/opensource/glx/license.html.
+
+Software distributed under the License is distributed on an "AS IS" basis.
+ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF NON-
+INFRINGEMENT. See the License for the specific language governing rights and
+limitations under the License.
+
+The Original Software is GLX version 1.2 source code, released February,
+1999. The developer of the Original Software is Silicon Graphics, Inc. Those
+portions of the Subject Software created by Silicon Graphics, Inc. are Copy-
+right (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved.
+
+3.5 CID Font Code Public License
+
+CID FONT CODE PUBLIC LICENSE (Version 1.0 (3/31/99))("License")
+
+Subject to any applicable third party claims, Silicon Graphics, Inc. ("SGI")
+hereby grants permission to Recipient (defined below), under SGI's copyrights
+in the Original Software (defined below), to use, copy, modify, merge, pub-
+lish, distribute, sublicense and/or sell copies of Subject Software (defined
+below) in both source code and executable form, and to permit persons to whom
+the Subject Software is furnished in accordance with this License to do the
+same, subject to all of the following terms and conditions, which Recipient
+accepts by engaging in any such use, copying, modifying, merging, publica-
+tion, distributing, sublicensing or selling:
+
+1. Definitions.
+
+ a. "Original Software" means source code of computer software code
+ that is described in Exhibit A as Original Software.
+
+ b. "Modifications" means any addition to or deletion from the sub-
+ stance or structure of either the Original Software or any previous
+ Modifications. When Subject Software is released as a series of
+ files, a Modification means (i) any addition to or deletion from
+ the contents of a file containing Original Software or previous
+ Modifications and (ii) any new file that contains any part of the
+ Original Code or previous Modifications.
+
+ c. "Subject Software" means the Original Software or Modifications
+ or the combination of the Original Software and Modifications, or
+ portions of any of the foregoing.
+
+ d. "Recipient" means an individual or a legal entity exercising
+ rights under the terms of this License. For legal entities, "Recip-
+ ient" includes any entity that controls, is controlled by, or is
+ under common control with Recipient. For purposes of this defini-
+ tion, "control" of an entity means (i) the power, direct or indi-
+ rect, to direct or manage such entity, or (ii) ownership of fifty
+ percent (50%) or more of the outstanding shares or beneficial own-
+ ership of such entity.
+
+ e. "Required Notice" means the notice set forth in Exhibit A to
+ this License.
+
+ f. "Accompanying Technology" means any software or other technology
+ that is not a Modification and that is distributed or made publicly
+ available by Recipient with the Subject Software. Separate soft-
+ ware files that do not contain any Original Software or any previ-
+ ous Modification shall not be deemed a Modification, even if such
+ software files are aggregated as part of a product, or in any
+ medium of storage, with any file that does contain Original Soft-
+ ware or any previous Modification.
+
+2. License Terms. All distribution of the Subject Software must be made sub-
+ject to the terms of this License. A copy of this License and the Required
+Notice must be included in any documentation for Subject Software where
+Recipient's rights relating to Subject Software and/or any Accompanying Tech-
+nology are described. Distributions of Subject Software in source code form
+must also include the Required Notice in every file distributed. In addition,
+a ReadMe file entitled "Important Legal Notice" must be distributed with each
+distribution of one or more files that incorporate Subject Software. That
+file must be included with distributions made in both source code and exe-
+cutable form. A copy of the License and the Required Notice must be included
+in that file. Recipient may distribute Accompanying Technology under a
+license of Recipient's choice, which may contain terms different from this
+License, provided that (i) Recipient is in compliance with the terms of this
+License, (ii) such other license terms do not modify or supersede the terms
+of this License as applicable to the Subject Software, (iii) Recipient hereby
+indemnifies SGI for any liability incurred by SGI as a result of the distri-
+bution of Accompanying Technology or the use of other license terms.
+
+3. Termination. This License and the rights granted hereunder will terminate
+automatically if Recipient fails to comply with terms herein and fails to
+cure such breach within 30 days of the breach. Any sublicense to the Subject
+Software that is properly granted shall survive any termination of this
+License absent termination by the terms of such sublicense. Provisions which,
+by their nature, must remain in effect beyond the termination of this License
+shall survive.
+
+4. Trademark Rights. This License does not grant any rights to use any trade
+name, trademark or service mark whatsoever. No trade name, trademark or ser-
+vice mark of SGI may be used to endorse or promote products derived from or
+incorporating any Subject Software without prior written permission of SGI.
+
+5. No Other Rights. No rights or licenses not expressly granted hereunder
+shall arise by implication, estoppel or otherwise. Title to and ownership of
+the Original Software at all times remains with SGI. All rights in the Origi-
+nal Software not expressly granted under this License are reserved.
+
+6. Compliance with Laws; Non-Infringement. Recipient shall comply with all
+applicable laws and regulations in connection with use and distribution of
+the Subject Software, including but not limited to, all export and import
+control laws and regulations of the U.S. government and other countries.
+Recipient may not distribute Subject Software that (i) in any way infringes
+(directly or contributorily) the rights (including patent, copyright, trade
+secret, trademark or other intellectual property rights of any kind) of any
+other person or entity, or (ii) breaches any representation or warranty,
+express, implied or statutory, which under any applicable law it might be
+deemed to have been distributed.
+
+7. Claims of Infringement. If Recipient at any time has knowledge of any one
+or more third party claims that reproduction, modification, use, distribu-
+tion, import or sale of Subject Software (including particular functionality
+or code incorporated in Subject Software) infringes the third party's intel-
+lectual property rights, Recipient must place in a well-identified web page
+bearing the title "LEGAL" a description of each such claim and a description
+of the party making each such claim in sufficient detail that a user of the
+Subject Software will know whom to contact regarding the claim. Also, upon
+gaining such knowledge of any such claim, Recipient must conspicuously
+include the URL for such web page in the Required Notice, and in the text of
+any related documentation, license agreement or collateral in which Recipient
+describes end user's rights relating to the Subject Software. If Recipient
+obtains such knowledge after it makes Subject Software available to any other
+person or entity, Recipient shall take other steps (such as notifying appro-
+priate mailing lists or newsgroups) reasonably calculated to provide such
+knowledge to those who received the Subject Software.
+
+8. DISCLAIMER OF WARRANTY. SUBJECT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT
+LIMITATION, WARRANTIES THAT THE SUBJECT SOFTWARE IS FREE OF DEFECTS, MER-
+CHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. SGI ASSUMES NO
+RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. SHOULD ANY SOFTWARE
+PROVE DEFECTIVE IN ANY RESPECT, SGI ASSUMES NO COST OR LIABILITY FOR ANY SER-
+VICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN
+ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY SUBJECT SOFTWARE IS AUTHORIZED
+HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY,
+WHETHER TORT (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE OR STRICT LIABILITY),
+CONTRACT, OR OTHERWISE, SHALL SGI OR ANY SGI LICENSOR 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 SUBJECT SOFTWARE OR
+THE USE OR OTHER DEALINGS IN THE SUBJECT SOFTWARE. SOME JURISDICTIONS DO NOT
+ALLOW THE EXCLUSION OR LIMITATION OF CERTAIN DAMAGES, SO THIS EXCLUSION AND
+LIMITATION MAY NOT APPLY TO RECIPIENT TO THE EXTENT SO DISALLOWED.
+
+10. Indemnity. Recipient shall be solely responsible for damages arising,
+directly or indirectly, out of its utilization of rights under this License.
+Recipient will defend, indemnify and hold SGI and its successors and assigns
+harmless from and against any loss, liability, damages, costs or expenses
+(including the payment of reasonable attorneys fees) arising out of (Recipi-
+ent's use, modification, reproduction and distribution of the Subject Soft-
+ware or out of any representation or warranty made by Recipient.
+
+11. U.S. Government End Users. The Subject Software is a "commercial item"
+consisting of "commercial computer software" as such terms are defined in
+title 48 of the Code of Federal Regulations and all U.S. Government End Users
+acquire only the rights set forth in this License and are subject to the
+terms of this License.
+
+12. Miscellaneous. This License represents the complete agreement concerning
+subject matter hereof. If any provision of this License is held to be unen-
+forceable by any judicial or administrative authority having proper jurisdic-
+tion with respect thereto, such provision shall be reformed so as to achieve
+as nearly as possible the same economic effect as the original provision and
+the remainder of this License will remain in effect. This License shall be
+governed by and construed in accordance with the laws of the United States
+and the State of California as applied to agreements entered into and to be
+performed entirely within California between California residents. Any liti-
+gation relating to this License shall be subject to the exclusive jurisdic-
+tion of the Federal Courts of the Northern District of California (or, absent
+subject matter jurisdiction in such courts, the courts of the State of Cali-
+fornia), with venue lying exclusively in Santa Clara County, California, with
+the losing party responsible for costs, including without limitation, court
+costs and reasonable attorneys fees and expenses. The application of the
+United Nations Convention on Contracts for the International Sale of Goods is
+expressly excluded. Any law or regulation that provides that the language of
+a contract shall be construed against the drafter shall not apply to this
+License.
+
+Exhibit A
+
+Copyright (c) 1994-1999 Silicon Graphics, Inc.
+
+The contents of this file are subject to the CID Font Code Public License
+Version 1.0 (the "License"). You may not use this file except in compliance
+with the License. You may obtain a copy of the License at Silicon Graphics,
+Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA 94043
+or at http://www.sgi.com/software/opensource/cid/license.html
+
+Software distributed under the License is distributed on an "AS IS" basis.
+ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF NON-
+INFRINGEMENT. See the License for the specific language governing rights and
+limitations under the License.
+
+The Original Software (as defined in the License) is CID font code that was
+developed by Silicon Graphics, Inc. Those portions of the Subject Software
+(as defined in the License) that were created by Silicon Graphics, Inc. are
+Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+
+[NOTE: When using this text in connection with Subject Software delivered
+solely in object code form, Recipient may replace the words "this file" with
+"this software" in both the first and second sentences.]
+
+3.6 Bitstream Vera Fonts Copyright
+
+The fonts have a generous copyright, allowing derivative works (as long as
+"Bitstream" or "Vera" are not in the names), and full redistribution (so long
+as they are not *sold* by themselves). They can be be bundled, redistributed
+and sold with any software.
+
+The fonts are distributed under the following copyright:
+
+Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
+a trademark of Bitstream, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of the fonts accompanying this license ("Fonts") and associated documentation
+files (the "Font Software"), to reproduce and distribute the Font Software,
+including without limitation the rights to use, copy, merge, publish, dis-
+tribute, and/or sell copies of the Font Software, and to permit persons to
+whom the Font Software is furnished to do so, subject to the following condi-
+tions:
+
+The above copyright and trademark notices and this permission notice shall be
+included in all copies of one or more of the Font Software typefaces.
+
+The Font Software may be modified, altered, or added to, and in particular
+the designs of glyphs or characters in the Fonts may be modified and addi-
+tional glyphs or characters may be added to the Fonts, only if the fonts are
+renamed to names not containing either the words "Bitstream" or the word
+"Vera".
+
+This License becomes null and void to the extent applicable to Fonts or Font
+Software that has been modified and is distributed under the "Bitstream Vera"
+names.
+
+The Font Software may be sold as part of a larger software package but no
+copy of one or more of the Font Software typefaces may be sold by itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDA-
+TION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GEN-
+ERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
+INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFT-
+WARE.
+
+Except as contained in this notice, the names of Gnome, the Gnome Foundation,
+and Bitstream Inc., shall not be used in advertising or otherwise to promote
+the sale, use or other dealings in this Font Software without prior written
+authorization from the Gnome Foundation or Bitstream Inc., respectively. For
+further information, contact: fonts at gnome dot org.
+
+3.7 Bigelow & Holmes Inc and URW++ GmbH Luxi font license
+
+Luxi fonts copyright (c) 2001 by Bigelow & Holmes Inc. Luxi font instruction
+code copyright (c) 2001 by URW++ GmbH. All Rights Reserved. Luxi is a regis-
+tered trademark of Bigelow & Holmes Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of these Fonts and associated documentation files (the "Font Software"), to
+deal in the Font Software, including without limitation the rights to use,
+copy, merge, publish, distribute, sublicense, and/or sell copies of the Font
+Software, and to permit persons to whom the Font Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright and trademark notices and this permission notice shall be
+included in all copies of one or more of the Font Software.
+
+The Font Software may not be modified, altered, or added to, and in particu-
+lar the designs of glyphs or characters in the Fonts may not be modified nor
+may additional glyphs or characters be added to the Fonts. This License
+becomes null and void when the Fonts or Font Software have been modified.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BIGELOW & HOLMES INC. OR URW++
+GMBH. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GEN-
+ERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
+INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFT-
+WARE.
+
+Except as contained in this notice, the names of Bigelow & Holmes Inc. and
+URW++ GmbH. shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Font Software without prior written
+authorization from Bigelow & Holmes Inc. and URW++ GmbH.
+
+For further information, contact:
+
+info@urwpp.de or design@bigelowandholmes.com
+
+ $Id: LICENSE,v 1.3 2004/09/03 23:41:21 kem Exp $
diff --git a/staging/xf86-video-v4l/PKGBUILD b/staging/xf86-video-v4l/PKGBUILD
new file mode 100644
index 000000000..07abf4e35
--- /dev/null
+++ b/staging/xf86-video-v4l/PKGBUILD
@@ -0,0 +1,36 @@
+# $Id: PKGBUILD 149896 2012-02-11 12:07:49Z andyrtr $
+#Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-v4l
+pkgver=0.2.0
+pkgrel=10
+pkgdesc="X.org v4l video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ git-fixes.patch
+ LICENSE)
+md5sums=('2251ae2a0a905764941cd7b098e85ad1'
+ 'cdb7113a9564ea9202e847de88440540'
+ '7d4d018f6bbff7e42672d1aabc75c5cf')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i "${srcdir}/git-fixes.patch"
+ autoreconf -fi
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-v4l/git-fixes.patch b/staging/xf86-video-v4l/git-fixes.patch
new file mode 100644
index 000000000..2f752fc8c
--- /dev/null
+++ b/staging/xf86-video-v4l/git-fixes.patch
@@ -0,0 +1,4362 @@
+diff --git a/ChangeLog b/ChangeLog
+deleted file mode 100644
+index 02fc6fa..0000000
+--- a/ChangeLog
++++ /dev/null
+@@ -1,57 +0,0 @@
+-2006-04-07 Adam Jackson <ajax@freedesktop.org>
+-
+- * configure.ac:
+- * src/v4l.c:
+- Bump to 0.1.1 for Xv changes.
+-
+-2006-04-07 Aaron Plattner <aplattner@nvidia.com>
+-
+- * src/v4l.c: (V4lPutVideo), (V4lPutStill):
+- Add a DrawablePtr argument to the XV functions to pave the way for
+- redirected video.
+-
+-2006-04-07 Adam Jackson <ajax@freedesktop.org>
+-
+- * configure.ac:
+- * src/v4l.c:
+- Unlibcwrap. Bump server version requirement. Bump to 0.1.0.
+-
+-2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version for X11R7 release.
+-
+-2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version number for final X11R7 release candidate.
+-
+-2005-12-06 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * man/Makefile.am:
+- Change *man_SOURCES ==> *man_PRE to fix autotools warnings.
+-
+-2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version number for X11R7 RC3 release.
+-
+-2005-12-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Remove extraneous AC_MSG_RESULT.
+-
+-2005-11-29 Adam Jackson <ajax@freedesktop.org>
+-
+- * configure.ac:
+- Only build dlloader modules by default.
+-
+-2005-11-09 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update package version number for X11R7 RC2 release.
+-
+-2005-11-01 Kevin E. Martin <kem-at-freedesktop-dot-org>
+-
+- * configure.ac:
+- Update pkgcheck dependencies to work with separate build roots.
+diff --git a/Makefile.am b/Makefile.am
+index 3ae2692..4c278ba 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -18,6 +18,15 @@
+ # 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
+-EXTRA_DIST = README
++MAINTAINERCLEANFILES = ChangeLog INSTALL
++
++.PHONY: ChangeLog INSTALL
++
++INSTALL:
++ $(INSTALL_CMD)
++
++ChangeLog:
++ $(CHANGELOG_CMD)
++
++dist-hook: ChangeLog INSTALL
+diff --git a/configure.ac b/configure.ac
+index d9ac542..c490919 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,57 +20,56 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-v4l],
+- 0.2.0,
++ [0.2.0],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-v4l)
+-
++ [xf86-video-v4l])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
+-AM_INIT_AUTOMAKE([dist-bzip2])
+-
++# Initialize Automake
++AM_INIT_AUTOMAKE([foreign dist-bzip2])
+ AM_MAINTAINER_MODE
+
+-# Checks for programs.
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
++m4_ifndef([XORG_MACROS_VERSION],
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
++XORG_DEFAULT_OPTIONS
++
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir,
+- AC_HELP_STRING([--with-xorg-module-dir=DIR],
++ AS_HELP_STRING([--with-xorg-module-dir=DIR],
+ [Default xorg module directory [[default=$libdir/xorg/modules]]]),
+ [moduledir="$withval"],
+ [moduledir="$libdir/xorg/modules"])
+
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(XV, videoproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto $REQUIRED_MODULES])
+-sdkdir=$(pkg-config --variable=sdkdir xorg-server)
+
+ # Checks for libraries.
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+-AC_SUBST([XORG_CFLAGS])
+ AC_SUBST([moduledir])
+
+ DRIVER_NAME=v4l
+ AC_SUBST([DRIVER_NAME])
+
+-XORG_MANPAGE_SECTIONS
+-XORG_RELEASE_VERSION
+-
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index f0eb29b..b3688ce 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,27 +1,24 @@
+ #
+ # 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.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a
++# copy of this software and associated documentation files (the "Software"),
++# to deal in the Software without restriction, including without limitation
++# the rights to use, copy, modify, merge, publish, distribute, sublicense,
++# and/or sell copies of the Software, and to permit persons to whom the
++# Software is furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++# DEALINGS IN THE SOFTWARE.
+ #
+
+ drivermandir = $(DRIVER_MAN_DIR)
+@@ -34,25 +31,11 @@ EXTRA_DIST = @DRIVER_NAME@.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+
+-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) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/v4l.man b/man/v4l.man
+index 7d35b86..dc1e201 100644
+--- a/man/v4l.man
++++ b/man/v4l.man
+@@ -34,6 +34,6 @@ Please refer to __xconfigfile__(__filemansuffix__) for general configuration
+ details. This section only covers configuration details specific to this
+ driver.
+ .SH "SEE ALSO"
+-__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
++__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
+ .SH AUTHORS
+ Authors include: Gerd Knorr <kraxel@bytesex.org>
+diff --git a/src/Makefile.am b/src/Makefile.am
+index ed30a80..08afe60 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -28,7 +28,6 @@ v4l_drv_la_LTLIBRARIES = v4l_drv.la
+ v4l_drv_la_LDFLAGS = -module -avoid-version
+ v4l_drv_ladir = @moduledir@/drivers
+
+-v4l_drv_la_SOURCES = \
+- v4l.c
+-
+-EXTRA_DIST = videodev.h
++v4l_drv_la_SOURCES = \
++ v4l.c \
++ videodev.h
+diff --git a/src/v4l.c b/src/v4l.c
+index b827f80..10e782b 100644
+--- a/src/v4l.c
++++ b/src/v4l.c
+@@ -1,6 +1,9 @@
+ /*
+- * video4linux Xv Driver
++ * video4linux Xv Driver
+ * based on Michael Schimek's permedia 2 driver.
++ *
++ * Copyright (c) 2011 Mauro Carvalho Chehab <mchehab@redhat.com> for:
++ * - Major rewrite, as driver got ported to V4L2 API
+ */
+
+ #ifdef HAVE_CONFIG_H
+@@ -9,12 +12,16 @@
+
+ #include <sys/types.h>
+ #include <sys/stat.h>
++#include <ctype.h>
++
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <string.h>
+ #include <stdio.h>
++#include <unistd.h>
++#include <sys/ioctl.h>
+
+-#include "videodev.h"
++#include "videodev2.h"
+ #include "xf86.h"
+ #include "xf86_OSproc.h"
+ #include "xf86Pci.h"
+@@ -25,8 +32,9 @@
+ #include "regionstr.h"
+ #include "dgaproc.h"
+ #include "xf86str.h"
++#include "fourcc.h"
+
+-#include <asm/ioctl.h> /* _IORW(xxx) #defines are here */
++#include <asm/ioctl.h> /* _IORW(xxx) #defines are here */
+
+ #if 0
+ # define DEBUG(x) (x)
+@@ -34,20 +42,22 @@
+ # define DEBUG(x)
+ #endif
+
++/***************************************************************************/
++
+ static void V4LIdentify(int flags);
+ static Bool V4LProbe(DriverPtr drv, int flags);
+ static const OptionInfoRec * V4LAvailableOptions(int chipid, int busid);
+
+ _X_EXPORT DriverRec V4L = {
+- 40000,
+- "v4l",
+- V4LIdentify, /* Identify*/
+- V4LProbe, /* Probe */
+- V4LAvailableOptions,
+- NULL,
+- 0
+-};
+-
++ .driverVersion = 50000,
++ .driverName = "v4l",
++ .Identify = V4LIdentify,
++ .Probe = V4LProbe,
++ .AvailableOptions = V4LAvailableOptions,
++ .module = NULL,
++ .refCount = 0,
++ .driverFunc = NULL, /* FIXME: Need to implement for new probing mode */
++};
+
+ #ifdef XFree86LOADER
+
+@@ -55,16 +65,16 @@ static MODULESETUPPROTO(v4lSetup);
+
+ static XF86ModuleVersionInfo v4lVersRec =
+ {
+- "v4l",
+- MODULEVENDORSTRING,
+- MODINFOSTRING1,
+- MODINFOSTRING2,
+- XORG_VERSION_CURRENT,
+- 0, 1, 1,
+- ABI_CLASS_VIDEODRV,
+- ABI_VIDEODRV_VERSION,
+- MOD_CLASS_NONE,
+- {0,0,0,0}
++ "v4l",
++ MODULEVENDORSTRING,
++ MODINFOSTRING1,
++ MODINFOSTRING2,
++ XORG_VERSION_CURRENT,
++ 0, 1, 1,
++ ABI_CLASS_VIDEODRV,
++ ABI_VIDEODRV_VERSION,
++ MOD_CLASS_NONE,
++ {0,0,0,0}
+ };
+
+ _X_EXPORT XF86ModuleData v4lModuleData = { &v4lVersRec, v4lSetup, NULL };
+@@ -72,32 +82,32 @@ _X_EXPORT XF86ModuleData v4lModuleData = { &v4lVersRec, v4lSetup, NULL };
+ static pointer
+ v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+ {
+- const char *osname;
+- static Bool setupDone = FALSE;
+-
+- if (setupDone) {
+- if (errmaj)
+- *errmaj = LDR_ONCEONLY;
+- return NULL;
+- }
+-
+- setupDone = TRUE;
+-
+- /* Check that we're being loaded on a Linux system */
+- LoaderGetOS(&osname, NULL, NULL, NULL);
+- if (!osname || strcmp(osname, "linux") != 0) {
+- if (errmaj)
+- *errmaj = LDR_BADOS;
+- if (errmin)
+- *errmin = 0;
+- return NULL;
+- } else {
+- /* OK */
+-
+- xf86AddDriver (&V4L, module, 0);
+-
+- return (pointer)1;
+- }
++ const char *osname;
++ static Bool setupDone = FALSE;
++
++ if (setupDone) {
++ if (errmaj)
++ *errmaj = LDR_ONCEONLY;
++ return NULL;
++ }
++
++ setupDone = TRUE;
++
++ /* Check that we're being loaded on a Linux system */
++ LoaderGetOS(&osname, NULL, NULL, NULL);
++ if (!osname || strcmp(osname, "linux") != 0) {
++ if (errmaj)
++ *errmaj = LDR_BADOS;
++ if (errmin)
++ *errmin = 0;
++ return NULL;
++ } else {
++ /* OK */
++
++ xf86AddDriver (&V4L, module, 0);
++
++ return (pointer)1;
++ }
+ }
+
+ #else
+@@ -112,25 +122,28 @@ v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+ #define VIDEO_YUV 2 /* yuv overlay (to offscreen memory + hw scaling) */
+ #define VIDEO_RECLIP 3 /* temporarly off, window clipping changes */
+
++typedef struct _XvV4LCtrlRec {
++ struct v4l2_queryctrl qctrl;
++ Atom xv;
++} XvV4LCtrlRec, *XvV4LCtrlPtr;
++
+ typedef struct _PortPrivRec {
+ ScrnInfoPtr pScrn;
+- FBAreaPtr pFBArea[2];
+- int VideoOn;
+- Bool StreamOn;
++ FBAreaPtr pFBArea[2];
++ int VideoOn;
++ Bool StreamOn;
+
+ /* file handle */
+- int nr;
+- struct video_capability cap;
++ int nr;
++ struct v4l2_capability cap;
+
+ /* RGB overlay */
+- struct video_buffer rgb_fbuf;
+- struct video_window rgb_win;
+- int rgbpalette;
++ struct v4l2_framebuffer rgb_fbuf;
++ struct v4l2_window rgb_win;
+ int rgbdepth;
+
+ /* attributes */
+- struct video_picture pict;
+- struct video_audio audio;
++ CARD32 pixelformat;
+
+ XF86VideoEncodingPtr enc;
+ int *input;
+@@ -145,24 +158,21 @@ typedef struct _PortPrivRec {
+
+ int yuv_width,yuv_height;
+ XF86SurfacePtr surface;
+- struct video_buffer yuv_fbuf;
+- struct video_window yuv_win;
+-} PortPrivRec, *PortPrivPtr;
++ struct v4l2_framebuffer yuv_fbuf;
++ struct v4l2_window yuv_win;
++
++ struct v4l2_standard *standard; /* FIXME: can be removed */
+
+-#define XV_ENCODING "XV_ENCODING"
+-#define XV_BRIGHTNESS "XV_BRIGHTNESS"
+-#define XV_CONTRAST "XV_CONTRAST"
+-#define XV_SATURATION "XV_SATURATION"
+-#define XV_HUE "XV_HUE"
++ XvV4LCtrlPtr XvV4LCtrl;
++ int n_qctrl;
++} PortPrivRec, *PortPrivPtr;
+
+-#define XV_FREQ "XV_FREQ"
+-#define XV_MUTE "XV_MUTE"
+-#define XV_VOLUME "XV_VOLUME"
++#define XV_ENCODING "XV_ENCODING"
++#define XV_FREQ "XV_FREQ"
+
+-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
++#define MAKE_ATOM(a) MakeAtom(a, strlen(a), TRUE)
+
+-static Atom xvEncoding, xvBrightness, xvContrast, xvSaturation, xvHue;
+-static Atom xvFreq, xvMute, xvVolume;
++static Atom xvEncoding, xvFreq;
+
+ static XF86VideoFormatRec
+ InputVideoFormats[] = {
+@@ -176,16 +186,8 @@ InputVideoFormats[] = {
+
+ static const XF86AttributeRec Attributes[] = {
+ {XvSettable | XvGettable, -1000, 1000, XV_ENCODING},
+- {XvSettable | XvGettable, -1000, 1000, XV_BRIGHTNESS},
+- {XvSettable | XvGettable, -1000, 1000, XV_CONTRAST},
+- {XvSettable | XvGettable, -1000, 1000, XV_SATURATION},
+- {XvSettable | XvGettable, -1000, 1000, XV_HUE},
+ };
+-static const XF86AttributeRec VolumeAttr =
+- {XvSettable | XvGettable, -1000, 1000, XV_VOLUME};
+-static const XF86AttributeRec MuteAttr =
+- {XvSettable | XvGettable, 0, 1, XV_MUTE};
+-static const XF86AttributeRec FreqAttr =
++static const XF86AttributeRec FreqAttr =
+ {XvSettable | XvGettable, 0, 16*1000, XV_FREQ};
+
+
+@@ -206,59 +208,247 @@ static struct V4L_DEVICE {
+ };
+
+ /* ---------------------------------------------------------------------- */
+-/* forward decl */
+
+-static void V4lQueryBestSize(ScrnInfoPtr pScrn, Bool motion,
+- short vid_w, short vid_h, short drw_w, short drw_h,
+- unsigned int *p_w, unsigned int *p_h, pointer data);
++static int SetV4LFmt(int fd, CARD32 pixelformat)
++{
++ struct v4l2_framebuffer fbuf;
++ char *p = (char *)&pixelformat;
++
++ memset(&fbuf, 0, sizeof(fbuf));
++ if (ioctl(fd, VIDIOC_G_FBUF, &fbuf) == -1) {
++ xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
++ return errno;
++ }
++ if (fbuf.fmt.pixelformat != pixelformat) {
++ fbuf.fmt.pixelformat = pixelformat;
++ if (ioctl(fd, VIDIOC_S_FBUF, &fbuf) == -1) {
++ xf86Msg(X_ERROR, "v4l: Error %d: Can't set FBUF to %c%c%c%c\n",
++ errno, p[0], p[1], p[2], p[3]);
++ return errno;
++ }
++ }
++ DEBUG(xf86Msg(X_INFO, "v4l: Set overlay format to %c%c%c%c\n",
++ p[0], p[1], p[2], p[3]));
++ return 0;
++}
++static int GetV4LFmt(int fd, CARD32 *pixelformat)
++{
++ struct v4l2_framebuffer fbuf;
++
++ memset(&fbuf, 0, sizeof(fbuf));
++ if (ioctl(fd, VIDIOC_G_FBUF, &fbuf) == -1) {
++ xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
++ return errno;
++ }
++
++ *pixelformat = fbuf.fmt.pixelformat;
++
++ return 0;
++}
++
++#define ATTR_NAME_PREFIX "XV_"
++static int AddControl(PortPrivPtr p, XF86AttributeRec **list, int *count,
++ struct v4l2_queryctrl *qctrl, int *n)
++{
++ char *ptr;
++
++/* v4l_add_attr */
++ if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED)
++ return 0;
++ switch (qctrl->type) {
++ case V4L2_CTRL_TYPE_INTEGER:
++ case V4L2_CTRL_TYPE_BOOLEAN:
++ case V4L2_CTRL_TYPE_MENU:
++ case V4L2_CTRL_TYPE_BUTTON:
++ break;
++ default:
++ return 0;
++ }
++
++ p->XvV4LCtrl = realloc(p->XvV4LCtrl, sizeof(XvV4LCtrlRec) * (*n + 1));
++ if (!p->XvV4LCtrl) {
++ if (*list) {
++ free (*list);
++ *count = 0;
++ *n = 0;
++ }
++ return -1;
++ }
++
++ *list = realloc(*list, sizeof(XF86AttributeRec) * (*count + 1));
++ if (NULL == *list) {
++ if (p->XvV4LCtrl)
++ free (p->XvV4LCtrl);
++ *count = 0;
++ return -1;
++ }
++
++ memset(*list + *count, 0, sizeof(XF86AttributeRec));
++ (*list)[*count].flags = XvSettable | XvGettable;
++
++ if (qctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)
++ (*list)[*count].flags &= ~XvSettable;
++ if (qctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)
++ (*list)[*count].flags &= ~XvGettable;
++ (*list)[*count].min_value = qctrl->minimum;
++ (*list)[*count].max_value = qctrl->maximum;
++ (*list)[*count].name = malloc(strlen((char *)qctrl->name) + 1 + sizeof (ATTR_NAME_PREFIX));
++ strcpy((*list)[*count].name, ATTR_NAME_PREFIX);
++ strcat((*list)[*count].name, (char *)qctrl->name);
++ for (ptr = (*list)[*count].name; *ptr; ptr++) {
++ *ptr = toupper(*ptr);
++ if (*ptr == ' ')
++ *ptr = '_';
++ }
++
++ p->XvV4LCtrl[*n].xv = MAKE_ATOM((*list)[*count].name);
++ memcpy(&p->XvV4LCtrl[*n].qctrl, qctrl, sizeof(*qctrl));
++
++ xf86Msg(X_INFO, "v4l: add attr %s (Xv/GPA %d) (%d to %d)\n",
++ (*list)[*count].name, (int)p->XvV4LCtrl[*n].xv,
++ p->XvV4LCtrl[*n].qctrl.minimum,
++ p->XvV4LCtrl[*n].qctrl.maximum);
++
++ (*count)++;
++ (*n)++;
++
++ return 0;
++}
++
++static void AddAllV4LControls(PortPrivPtr p, XF86AttributeRec **list,
++ int *count, int fd)
++{
++ int entries = 0;
++ CARD32 id;
++ struct v4l2_queryctrl qctrl;
++
++ memset(&qctrl, 0, sizeof(qctrl));
++ qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
++ while (!ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) {
++ if (AddControl(p, list, count, &qctrl, &entries))
++ return;
++ qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
++ }
++ if (qctrl.id != V4L2_CTRL_FLAG_NEXT_CTRL)
++ return;
++ for (id = V4L2_CID_USER_BASE; id < V4L2_CID_LASTP1; id++) {
++ qctrl.id = id;
++ if (!ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) {
++ if (AddControl(p, list, count, &qctrl, &entries))
++ return;
++ }
++ }
++ qctrl.id = V4L2_CID_PRIVATE_BASE;
++ while (!ioctl(fd, VIDIOC_QUERYCTRL, &qctrl)) {
++ if (AddControl(p, list, count, &qctrl, &entries))
++ return;
++ qctrl.id++;
++ }
++ p->n_qctrl = entries;
++}
+
+ /* ---------------------------------------------------------------------- */
+
++/* setup yuv overlay + hw scaling: look if we find some common video
++ format which both v4l driver and the X-Server can handle */
++static int v4l_check_yuv(ScrnInfoPtr pScrn, PortPrivPtr pPPriv,
++ char *dev, int fd)
++{
++ static const struct {
++ CARD32 v4l_palette;
++ unsigned int xv_id;
++ unsigned int xv_format;
++ } yuvlist[] = {
++ { V4L2_PIX_FMT_YUYV, FOURCC_YUY2, XvPacked },
++ { V4L2_PIX_FMT_UYVY, FOURCC_UYVY, XvPacked },
++ { 0 /* end of list */ },
++ };
++ /* FIXME: Why pScrn->scrnIndex? */
++ ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
++ int fmt,i;
++
++ pPPriv->format = xf86XVQueryOffscreenImages(pScreen, &pPPriv->nformat);
++ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
++ "v4l: Number of Xv formats: %d\n", pPPriv->nformat);
++ if (!pPPriv->nformat)
++ return FALSE;
++
++ for (fmt = 0; yuvlist[fmt].v4l_palette != 0; fmt++) {
++ pPPriv->pixelformat = yuvlist[fmt].v4l_palette;
++ if (-1 == SetV4LFmt(fd, pPPriv->pixelformat))
++ continue;
++ GetV4LFmt(fd, &pPPriv->pixelformat);
++ if (pPPriv->pixelformat != yuvlist[fmt].v4l_palette)
++ continue;
++ /* ... works, check available offscreen image formats now ... */
++ for (i = 0; i < pPPriv->nformat; i++) {
++ if (pPPriv->format[i].image->id == yuvlist[fmt].xv_id &&
++ pPPriv->format[i].image->format == yuvlist[fmt].xv_format) {
++ /* ... match found, good. */
++ pPPriv->yuv_format = yuvlist[fmt].v4l_palette;
++ pPPriv->myfmt = pPPriv->format+i;
++ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
++ "v4l[%s]: using hw video scaling [%4.4s].\n",
++ dev,(char*)&(pPPriv->format[i].image->id));
++ return TRUE;
++ }
++ }
++ }
++ return TRUE;
++}
++
+ static int V4lOpenDevice(PortPrivPtr pPPriv, ScrnInfoPtr pScrn)
+ {
+ static int first = 1;
+
++#if 0
++ /*
++ * It may be a good idea to probe here, but this would break
++ * some things, as initialization uses yuv_format
++ */
++ if (!pPPriv->yuv_format && first)
++ v4l_check_yuv(pScrn, pPPriv, V4L_NAME, V4L_FD);
++#endif
+ if (-1 == V4L_FD) {
+- V4L_FD = open(V4L_NAME, O_RDWR, 0);
+-
+- pPPriv->rgb_fbuf.width = pScrn->virtualX;
+- pPPriv->rgb_fbuf.height = pScrn->virtualY;
+- pPPriv->rgb_fbuf.depth = pScrn->bitsPerPixel;
+- pPPriv->rgb_fbuf.bytesperline = pScrn->displayWidth * ((pScrn->bitsPerPixel + 7)/8);
+- pPPriv->rgb_fbuf.base = (pointer)(pScrn->memPhysBase + pScrn->fbOffset);
+- if (first) {
+- first = 0;
+- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+- "v4l: memPhysBase=0x%lx\n", pScrn->memPhysBase);
+- }
+-
+- switch (pScrn->bitsPerPixel) {
+- case 16:
+- if (pScrn->weight.green == 5) {
+- pPPriv->rgbpalette = VIDEO_PALETTE_RGB555;
+- pPPriv->rgbdepth = 16;
+- } else {
+- pPPriv->rgbpalette = VIDEO_PALETTE_RGB565;
+- pPPriv->rgbdepth = 16;
+- }
+- break;
+- case 24:
+- pPPriv->rgbpalette = VIDEO_PALETTE_RGB24;
+- pPPriv->rgbdepth = 24;
+- break;
+- case 32:
+- pPPriv->rgbpalette = VIDEO_PALETTE_RGB32;
+- pPPriv->rgbdepth = 32;
+- break;
+- }
++ V4L_FD = open(V4L_NAME, O_RDWR, 0);
++
++ if (-1 == V4L_FD)
++ return errno;
++
++ if (-1 == ioctl(V4L_FD, VIDIOC_G_FBUF, &pPPriv->rgb_fbuf)) {
++ xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
++ return errno;
++ }
++ pPPriv->rgb_fbuf.fmt.width = pScrn->virtualX;
++ pPPriv->rgb_fbuf.fmt.height = pScrn->virtualY;
++ pPPriv->rgb_fbuf.fmt.bytesperline = pScrn->displayWidth * ((pScrn->bitsPerPixel + 7)/8);
++ pPPriv->rgb_fbuf.base = (pointer)(pScrn->memPhysBase + pScrn->fbOffset);
++ if (first) {
++ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
++ "v4l: memPhysBase=0x%lx\n", pScrn->memPhysBase);
++ first = 0;
++ }
++
++ switch (pScrn->bitsPerPixel) {
++ case 16:
++ if (pScrn->weight.green == 5) {
++ pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555;
++ } else {
++ pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565;
++ }
++ break;
++ case 24:
++ pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24;
++ break;
++ case 32:
++ pPPriv->rgb_fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
++ break;
++ }
+ }
+
+- if (-1 == V4L_FD)
+- return errno;
+-
+ V4L_REF++;
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+- "Xv/open: refcount=%d\n",V4L_REF));
++ "Xv/open: refcount=%d\n",V4L_REF));
+
+ return 0;
+ }
+@@ -267,10 +457,10 @@ static void V4lCloseDevice(PortPrivPtr pPPriv, ScrnInfoPtr pScrn)
+ {
+ V4L_REF--;
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+- "Xv/close: refcount=%d\n",V4L_REF));
++ "Xv/close: refcount=%d\n",V4L_REF));
+ if (0 == V4L_REF && -1 != V4L_FD) {
+- close(V4L_FD);
+- V4L_FD = -1;
++ close(V4L_FD);
++ V4L_FD = -1;
+ }
+ }
+
+@@ -280,8 +470,10 @@ V4lPutVideo(ScrnInfoPtr pScrn,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ RegionPtr clipBoxes, pointer data, DrawablePtr pDraw)
+ {
++ struct v4l2_format fmt;
++
+ PortPrivPtr pPPriv = (PortPrivPtr) data;
+- struct video_clip *clip;
++ struct v4l2_clip *clip;
+ BoxPtr pBox;
+ RegionRec newReg;
+ BoxRec newBox;
+@@ -291,179 +483,214 @@ V4lPutVideo(ScrnInfoPtr pScrn,
+
+ /* Open a file handle to the device */
+ if (VIDEO_OFF == pPPriv->VideoOn) {
+- if (V4lOpenDevice(pPPriv, pScrn))
+- return Success;
++ if (V4lOpenDevice(pPPriv, pScrn))
++ return Success;
+ }
+
+ if (0 != pPPriv->yuv_format) {
+- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV yuv\n"));
+- width = pPPriv->enc[pPPriv->cenc].width;
++ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV yuv\n"));
++ width = pPPriv->enc[pPPriv->cenc].width;
+ height = pPPriv->enc[pPPriv->cenc].height/2; /* no interlace */
+- if (drw_w < width)
+- width = drw_w;
+- if (drw_h < height)
+- height = drw_h;
+- if ((height != pPPriv->yuv_height) || (width != pPPriv->yuv_width)) {
+- /* new size -- free old surface */
+- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface resize\n"));
+- if (pPPriv->surface) {
+- pPPriv->VideoOn = VIDEO_OFF;
+- pPPriv->myfmt->stop(pPPriv->surface);
+- pPPriv->myfmt->free_surface(pPPriv->surface);
+- xfree(pPPriv->surface);
+- pPPriv->surface = NULL;
+- }
+- pPPriv->yuv_width = width;
+- pPPriv->yuv_height = height;
+- }
+- if (!pPPriv->surface) {
+- /* allocate + setup offscreen surface */
+- if (NULL == (pPPriv->surface = xalloc(sizeof(XF86SurfaceRec))))
+- return FALSE;
+- if (Success != pPPriv->myfmt->alloc_surface
+- (pScrn,pPPriv->myfmt->image->id,
+- pPPriv->yuv_width,pPPriv->yuv_height,pPPriv->surface)) {
+- xfree(pPPriv->surface);
+- pPPriv->surface = NULL;
+- goto fallback_to_rgb;
+- }
+- pPPriv->yuv_fbuf.width = pPPriv->surface->width;
+- pPPriv->yuv_fbuf.height = pPPriv->surface->height;
+- pPPriv->yuv_fbuf.depth = 16;
+- pPPriv->yuv_fbuf.bytesperline = pPPriv->surface->pitches[0];
+- pPPriv->yuv_fbuf.base =
+- (pointer)(pScrn->memPhysBase + pPPriv->surface->offsets[0]);
+- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface: %p+%d = %p, %dx%d, pitch %d\n",
+- pScrn->memPhysBase,pPPriv->surface->offsets[0],
+- pScrn->memPhysBase+pPPriv->surface->offsets[0],
+- pPPriv->surface->width,pPPriv->surface->height,
+- pPPriv->surface->pitches[0]));
+- pPPriv->yuv_win.width = pPPriv->surface->width;
+- pPPriv->yuv_win.height = pPPriv->surface->height;
+- }
+-
+- /* program driver */
+- if (-1 == ioctl(V4L_FD,VIDIOCSFBUF,&(pPPriv->yuv_fbuf)))
+- perror("ioctl VIDIOCSFBUF");
+- if (-1 == ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict))
+- perror("ioctl VIDIOCGPICT");
+- pPPriv->pict.palette = pPPriv->yuv_format;
+- pPPriv->pict.depth = 16;
+- if (-1 == ioctl(V4L_FD,VIDIOCSPICT,&pPPriv->pict))
+- perror("ioctl VIDIOCSPICT");
+- if (-1 == ioctl(V4L_FD,VIDIOCSWIN,&(pPPriv->yuv_win)))
+- perror("ioctl VIDIOCSWIN");
+- if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &one))
+- perror("ioctl VIDIOCCAPTURE(1)");
+-
+- if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
+- /* invert cliplist */
+- newBox.x1 = drw_x;
+- newBox.y1 = drw_y;
+- newBox.x2 = drw_x + drw_w;
+- newBox.y2 = drw_y + drw_h;
+-
+- if (pPPriv->myfmt->flags & VIDEO_CLIP_TO_VIEWPORT) {
+- /* trim to the viewport */
+- if(newBox.x1 < pScrn->frameX0)
+- newBox.x1 = pScrn->frameX0;
+- if(newBox.x2 > pScrn->frameX1)
+- newBox.x2 = pScrn->frameX1;
+-
+- if(newBox.y1 < pScrn->frameY0)
+- newBox.y1 = pScrn->frameY0;
+- if(newBox.y2 > pScrn->frameY1)
+- newBox.y2 = pScrn->frameY1;
+- }
++ if (drw_w < width)
++ width = drw_w;
++ if (drw_h < height)
++ height = drw_h;
++ if ((height != pPPriv->yuv_height) || (width != pPPriv->yuv_width)) {
++ /* new size -- free old surface */
++ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface resize\n"));
++ if (pPPriv->surface) {
++ pPPriv->VideoOn = VIDEO_OFF;
++ pPPriv->myfmt->stop(pPPriv->surface);
++ pPPriv->myfmt->free_surface(pPPriv->surface);
++ free(pPPriv->surface);
++ pPPriv->surface = NULL;
++ }
++ pPPriv->yuv_width = width;
++ pPPriv->yuv_height = height;
++ }
++ if (!pPPriv->surface) {
++ /* allocate + setup offscreen surface */
++ if (NULL == (pPPriv->surface = malloc(sizeof(XF86SurfaceRec))))
++ return FALSE;
++ if (Success != pPPriv->myfmt->alloc_surface
++ (pScrn,pPPriv->myfmt->image->id,
++ pPPriv->yuv_width,pPPriv->yuv_height,pPPriv->surface)) {
++ free(pPPriv->surface);
++ pPPriv->surface = NULL;
++ goto fallback_to_rgb;
++ }
++
++ if (-1 == ioctl(V4L_FD, VIDIOC_G_FBUF, &pPPriv->yuv_fbuf)) {
++ xf86Msg(X_ERROR, "v4l: Error %d: Can't get FBUF\n", errno);
++ return errno;
++ }
++ pPPriv->yuv_fbuf.fmt.width = pPPriv->surface->width;
++ pPPriv->yuv_fbuf.fmt.height = pPPriv->surface->height;
++ pPPriv->yuv_fbuf.fmt.bytesperline = pPPriv->surface->pitches[0];
++ pPPriv->yuv_fbuf.fmt.pixelformat = pPPriv->yuv_format;
++ pPPriv->yuv_fbuf.base =
++ (pointer)(pScrn->memPhysBase + pPPriv->surface->offsets[0]);
++ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
++ " surface: %p+%d = %p, %dx%d, pitch %d\n",
++ (void *)pScrn->memPhysBase, pPPriv->surface->offsets[0],
++ (void *)pScrn->memPhysBase+pPPriv->surface->offsets[0],
++ pPPriv->surface->width, pPPriv->surface->height,
++ pPPriv->surface->pitches[0]));
++ memset(&pPPriv->yuv_win, 0, sizeof(pPPriv->yuv_win));
++ pPPriv->yuv_win.w.left = 0;
++ pPPriv->yuv_win.w.top = 0;
++ pPPriv->yuv_win.w.width = pPPriv->surface->width;
++ pPPriv->yuv_win.w.height = pPPriv->surface->height;
++ }
+
+- REGION_INIT(pScrn->pScreen, &newReg, &newBox, 1);
+- REGION_SUBTRACT(pScrn->pScreen, &newReg, &newReg, clipBoxes);
+- clipBoxes = &newReg;
+- }
+-
+- /* start overlay */
+- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+- "over: - %d,%d -> %d,%d (%dx%d) (yuv=%dx%d)\n",
+- drw_x, drw_y,
+- drw_x+drw_w, drw_y+drw_h,
+- drw_w, drw_h,
+- pPPriv->surface->width,pPPriv->surface->height));
+- pPPriv->myfmt->display(pPPriv->surface,
+- 0, 0, drw_x, drw_y,
+- pPPriv->surface->width,
+- pPPriv->surface->height,
+- drw_w, drw_h,
+- clipBoxes);
+- if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
+- REGION_UNINIT(pScrn->pScreen, &newReg);
+- }
+- pPPriv->VideoOn = VIDEO_YUV;
+- return Success;
++ /* program driver */
++ if (-1 == ioctl(V4L_FD, VIDIOC_S_FBUF, &pPPriv->yuv_fbuf)) {
++ xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FBUF\n", errno);
++ return BadValue;
++ }
++ pPPriv->pixelformat = pPPriv->yuv_format;
++ if (-1 == SetV4LFmt(V4L_FD, pPPriv->pixelformat))
++ return BadValue;
++
++ memset(&fmt, 0, sizeof(fmt));
++ fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
++ memcpy(&fmt.fmt.win, &pPPriv->yuv_win, sizeof(pPPriv->yuv_win));
++ if (-1 == ioctl(V4L_FD, VIDIOC_S_FMT, &fmt)) {
++ xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FMT\n", errno);
++ return BadValue;
++ }
++ if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &one)) {
++ xf86Msg(X_ERROR, "v4l: Error %d while enabling Overlay\n", errno);
++ return BadValue;
++ }
++
++ if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
++ /* invert cliplist */
++ newBox.x1 = drw_x;
++ newBox.y1 = drw_y;
++ newBox.x2 = drw_x + drw_w;
++ newBox.y2 = drw_y + drw_h;
++
++ if (pPPriv->myfmt->flags & VIDEO_CLIP_TO_VIEWPORT) {
++ /* trim to the viewport */
++ if(newBox.x1 < pScrn->frameX0)
++ newBox.x1 = pScrn->frameX0;
++ if(newBox.x2 > pScrn->frameX1)
++ newBox.x2 = pScrn->frameX1;
++
++ if(newBox.y1 < pScrn->frameY0)
++ newBox.y1 = pScrn->frameY0;
++ if(newBox.y2 > pScrn->frameY1)
++ newBox.y2 = pScrn->frameY1;
++ }
++
++ REGION_INIT(pScrn->pScreen, &newReg, &newBox, 1);
++ REGION_SUBTRACT(pScrn->pScreen, &newReg, &newReg, clipBoxes);
++ clipBoxes = &newReg;
++ }
++
++ /* start overlay */
++ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
++ "over: - %d,%d -> %d,%d (%dx%d) (yuv=%dx%d)\n",
++ drw_x, drw_y,
++ drw_x+drw_w, drw_y+drw_h,
++ drw_w, drw_h,
++ pPPriv->surface->width,pPPriv->surface->height));
++ pPPriv->myfmt->display(pPPriv->surface,
++ 0, 0, drw_x, drw_y,
++ pPPriv->surface->width,
++ pPPriv->surface->height,
++ drw_w, drw_h,
++ clipBoxes);
++ if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
++ REGION_UNINIT(pScrn->pScreen, &newReg);
++ }
++ pPPriv->VideoOn = VIDEO_YUV;
++ return Success;
+ }
+
+- fallback_to_rgb:
++fallback_to_rgb:
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV rgb\n"));
+ /* FIXME: vid-* is ignored for now, not supported by v4l */
+
+ dw = (drw_w < pPPriv->enc[pPPriv->cenc].width) ?
+- drw_w : pPPriv->enc[pPPriv->cenc].width;
++ drw_w : pPPriv->enc[pPPriv->cenc].width;
+ dh = (drw_h < pPPriv->enc[pPPriv->cenc].height) ?
+- drw_h : pPPriv->enc[pPPriv->cenc].height;
++ drw_h : pPPriv->enc[pPPriv->cenc].height;
+ /* if the window is too big, center the video */
+ dx = drw_x + (drw_w - dw)/2;
+ dy = drw_y + (drw_h - dh)/2;
+ /* bttv prefeares aligned addresses */
+ dx &= ~3;
+- if (dx < drw_x) dx += 4;
+- if (dx+dw > drw_x+drw_w) dw -= 4;
++ if (dx < drw_x)
++ dx += 4;
++ if (dx+dw > drw_x+drw_w)
++ dw -= 4;
+
+ /* window */
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " win: %dx%d+%d+%d\n",
+- drw_w,drw_h,drw_x,drw_y));
++ drw_w,drw_h,drw_x,drw_y));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " use: %dx%d+%d+%d\n",
+- dw,dh,dx,dy));
+- pPPriv->rgb_win.x = dx;
+- pPPriv->rgb_win.y = dy;
+- pPPriv->rgb_win.width = dw;
+- pPPriv->rgb_win.height = dh;
+- pPPriv->rgb_win.flags = 0;
+-
++ dw,dh,dx,dy));
++ memset(&pPPriv->rgb_win, 0, sizeof(pPPriv->rgb_win));
++ pPPriv->rgb_win.w.left = dx;
++ pPPriv->rgb_win.w.top = dy;
++ pPPriv->rgb_win.w.width = dw;
++ pPPriv->rgb_win.w.height = dh;
++
+ /* clipping */
+ if (pPPriv->rgb_win.clips) {
+- xfree(pPPriv->rgb_win.clips);
+- pPPriv->rgb_win.clips = NULL;
++ free(pPPriv->rgb_win.clips);
++ pPPriv->rgb_win.clips = NULL;
+ }
+ pPPriv->rgb_win.clipcount = REGION_NUM_RECTS(clipBoxes);
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2," clip: have #%d\n",
+- pPPriv->rgb_win.clipcount));
++ pPPriv->rgb_win.clipcount));
+ if (0 != pPPriv->rgb_win.clipcount) {
+- pPPriv->rgb_win.clips = xalloc(pPPriv->rgb_win.clipcount*sizeof(struct video_clip));
+- if (NULL != pPPriv->rgb_win.clips) {
+- memset(pPPriv->rgb_win.clips,0,pPPriv->rgb_win.clipcount*sizeof(struct video_clip));
+- pBox = REGION_RECTS(clipBoxes);
+- clip = pPPriv->rgb_win.clips;
+- for (i = 0; i < REGION_NUM_RECTS(clipBoxes); i++, pBox++, clip++) {
+- clip->x = pBox->x1 - dx;
+- clip->y = pBox->y1 - dy;
+- clip->width = pBox->x2 - pBox->x1;
+- clip->height = pBox->y2 - pBox->y1;
+- }
+- }
++ pPPriv->rgb_win.clips = malloc(pPPriv->rgb_win.clipcount*sizeof(struct v4l2_clip));
++ if (NULL != pPPriv->rgb_win.clips) {
++ memset(pPPriv->rgb_win.clips,0,pPPriv->rgb_win.clipcount*sizeof(struct v4l2_clip));
++ pBox = REGION_RECTS(clipBoxes);
++ clip = pPPriv->rgb_win.clips;
++
++ /*
++ * FIXME: This code currently does nothing, as we don't emulate
++ * The V4L1 clipping stuff
++ */
++ for (i = 0; i < REGION_NUM_RECTS(clipBoxes); i++, pBox++, clip++) {
++ clip->c.left = pBox->x1 - dx;
++ clip->c.top = pBox->y1 - dy;
++ clip->c.width = pBox->x2 - pBox->x1;
++ clip->c.height = pBox->y2 - pBox->y1;
++ }
++ }
+ }
+
+ /* start */
+- if (-1 == ioctl(V4L_FD,VIDIOCSFBUF,&(pPPriv->rgb_fbuf)))
+- perror("ioctl VIDIOCSFBUF");
+- if (-1 == ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict))
+- perror("ioctl VIDIOCGPICT");
+- pPPriv->pict.palette = pPPriv->rgbpalette;
+- pPPriv->pict.depth = pPPriv->rgbdepth;
+- if (-1 == ioctl(V4L_FD,VIDIOCSPICT,&pPPriv->pict))
+- perror("ioctl VIDIOCSPICT");
+- if (-1 == ioctl(V4L_FD,VIDIOCSWIN,&(pPPriv->rgb_win)))
+- perror("ioctl VIDIOCSWIN");
+- if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &one))
+- perror("ioctl VIDIOCCAPTURE(1)");
++ if (-1 == ioctl(V4L_FD, VIDIOC_S_FBUF, &pPPriv->rgb_fbuf)) {
++ xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FBUF\n", errno);
++ return BadValue;
++ }
++ if (-1 == GetV4LFmt(V4L_FD, &pPPriv->pixelformat)) {
++ xf86Msg(X_ERROR, "Error %d getting pixelformat\n", errno);
++ return BadValue;
++ }
++ pPPriv->pixelformat = pPPriv->rgb_fbuf.fmt.pixelformat;
++ if (-1 == SetV4LFmt(V4L_FD, pPPriv->pixelformat)) {
++ xf86Msg(X_ERROR, "Error %d getting pixelformat\n", errno);
++ return BadValue;
++ }
++ memset(&fmt, 0, sizeof(fmt));
++ fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
++ memcpy(&fmt.fmt.win, &pPPriv->rgb_win, sizeof(pPPriv->rgb_win));
++ if (-1 == ioctl(V4L_FD, VIDIOC_S_FMT, &fmt)) {
++ xf86Msg(X_ERROR, "Error %d at VIDIOC_S_FMT\n", errno);
++ return BadValue;
++ }
++ if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &one)) {
++ xf86Msg(X_ERROR, "v4l: Error %d while enabling Overlay\n", errno);
++ return BadValue;
++ }
+ pPPriv->VideoOn = VIDEO_RGB;
+
+ return Success;
+@@ -476,7 +703,7 @@ V4lPutStill(ScrnInfoPtr pScrn,
+ RegionPtr clipBoxes, pointer data, DrawablePtr pDraw)
+ {
+ #if 0
+- PortPrivPtr pPPriv = (PortPrivPtr) data;
++ PortPrivPtr pPPriv = (PortPrivPtr) data;
+ #endif
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PS\n"));
+@@ -488,177 +715,152 @@ V4lPutStill(ScrnInfoPtr pScrn,
+ static void
+ V4lStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
+ {
+- PortPrivPtr pPPriv = (PortPrivPtr) data;
++ PortPrivPtr pPPriv = (PortPrivPtr) data;
+ int zero=0;
+
+ if (VIDEO_OFF == pPPriv->VideoOn) {
+- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+- "Xv/StopVideo called with video already off\n"));
+- return;
++ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
++ "Xv/StopVideo called with video already off\n"));
++ return;
+ }
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/StopVideo shutdown=%d\n",shutdown));
+
+ if (!shutdown) {
+- /* just reclipping, we have to stop DMA transfers to the visible screen */
+- if (VIDEO_RGB == pPPriv->VideoOn) {
+- if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &zero))
+- perror("ioctl VIDIOCCAPTURE(0)");
+- pPPriv->VideoOn = VIDEO_RECLIP;
+- }
++ /* just reclipping, we have to stop DMA transfers to the visible screen */
++ if (VIDEO_RGB == pPPriv->VideoOn) {
++ if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &zero))
++ xf86Msg(X_ERROR, "v4l: Error %d while disabling Overlay\n", errno);
++ pPPriv->VideoOn = VIDEO_RECLIP;
++ }
+ } else {
+- /* video stop - turn off and free everything */
+- if (VIDEO_YUV == pPPriv->VideoOn) {
+- pPPriv->myfmt->stop(pPPriv->surface);
+- pPPriv->myfmt->free_surface(pPPriv->surface);
+- xfree(pPPriv->surface);
+- pPPriv->surface = NULL;
+- }
+- if (-1 == ioctl(V4L_FD, VIDIOCCAPTURE, &zero))
+- perror("ioctl VIDIOCCAPTURE(0)");
+-
+- V4lCloseDevice(pPPriv,pScrn);
+- pPPriv->VideoOn = VIDEO_OFF;
+- }
+-}
++ /* video stop - turn off and free everything */
++ if (VIDEO_YUV == pPPriv->VideoOn) {
++ pPPriv->myfmt->stop(pPPriv->surface);
++ pPPriv->myfmt->free_surface(pPPriv->surface);
++ free(pPPriv->surface);
++ pPPriv->surface = NULL;
++ }
++ if (-1 == ioctl(V4L_FD, VIDIOC_OVERLAY, &zero))
++ xf86Msg(X_ERROR, "v4l: Error %d while disabling Overlay\n", errno);
+
+-/* v4l uses range 0 - 65535; Xv uses -1000 - 1000 */
+-static int
+-v4l_to_xv(int val) {
+- val = val * 2000 / 65536 - 1000;
+- if (val < -1000) val = -1000;
+- if (val > 1000) val = 1000;
+- return val;
+-}
+-static int
+-xv_to_v4l(int val) {
+- val = val * 65536 / 2000 + 32768;
+- if (val < -0) val = 0;
+- if (val > 65535) val = 65535;
+- return val;
++ V4lCloseDevice(pPPriv,pScrn);
++ pPPriv->VideoOn = VIDEO_OFF;
++ }
+ }
+
+ static int
+ V4lSetPortAttribute(ScrnInfoPtr pScrn,
+ Atom attribute, INT32 value, pointer data)
+ {
+- PortPrivPtr pPPriv = (PortPrivPtr) data;
+- struct video_channel chan;
+- int ret = Success;
++ struct v4l2_control ctrl;
++ PortPrivPtr pPPriv = (PortPrivPtr) data;
++ int i, ret = BadValue;
+
+ if (V4lOpenDevice(pPPriv, pScrn))
+- return Success;
++ return Success;
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/SPA %d, %d\n",
+- attribute, value));
++ (int)attribute, (int)value));
+
+ if (-1 == V4L_FD) {
+- ret = Success;
++ ret = Success;
+ } else if (attribute == xvEncoding) {
+- if (value >= 0 && value < pPPriv->nenc) {
+- pPPriv->cenc = value;
+- chan.channel = pPPriv->input[value];
+- chan.norm = pPPriv->norm[value];
+- if (-1 == ioctl(V4L_FD,VIDIOCSCHAN,&chan))
+- perror("ioctl VIDIOCSCHAN");
+- } else {
+- ret = BadValue;
+- }
+- } else if (attribute == xvBrightness ||
+- attribute == xvContrast ||
+- attribute == xvSaturation ||
+- attribute == xvHue) {
+- ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict);
+- if (attribute == xvBrightness) pPPriv->pict.brightness = xv_to_v4l(value);
+- if (attribute == xvContrast) pPPriv->pict.contrast = xv_to_v4l(value);
+- if (attribute == xvSaturation) pPPriv->pict.colour = xv_to_v4l(value);
+- if (attribute == xvHue) pPPriv->pict.hue = xv_to_v4l(value);
+- if (-1 == ioctl(V4L_FD,VIDIOCSPICT,&pPPriv->pict))
+- perror("ioctl VIDIOCSPICT");
+- } else if (attribute == xvMute ||
+- attribute == xvVolume) {
+- ioctl(V4L_FD,VIDIOCGAUDIO,&pPPriv->audio);
+- if (attribute == xvMute) {
+- if (value)
+- pPPriv->audio.flags |= VIDEO_AUDIO_MUTE;
+- else
+- pPPriv->audio.flags &= ~VIDEO_AUDIO_MUTE;
+- } else if (attribute == xvVolume) {
+- if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
+- pPPriv->audio.volume = xv_to_v4l(value);
+- } else {
+- ret = BadValue;
+- }
+- if (ret != BadValue)
+- if (-1 == ioctl(V4L_FD,VIDIOCSAUDIO,&pPPriv->audio))
+- perror("ioctl VIDIOCSAUDIO");
++ if (value < 0 || value >= pPPriv->nenc)
++ goto err;
++ if (ioctl(V4L_FD, VIDIOC_S_INPUT, &pPPriv->input[value]) == -1) {
++ xf86Msg(X_ERROR, "v4l: Error %d while setting input\n", errno);
++ goto err;
++ }
++ if (ioctl(V4L_FD, VIDIOC_S_STD, &pPPriv->norm[value]) == -1) {
++ xf86Msg(X_ERROR, "v4l: Error %d while setting standard\n", errno);
++ goto err;
++ }
++ pPPriv->cenc = value;
++ ret = Success;
+ } else if (attribute == xvFreq) {
+- unsigned long freq = value;
+- if (-1 == ioctl(V4L_FD,VIDIOCSFREQ,&freq))
+- perror("ioctl VIDIOCSFREQ");
+- } else if (0 != pPPriv->yuv_format &&
+- pPPriv->myfmt->setAttribute) {
+- /* not mine -> pass to yuv scaler driver */
+- ret = pPPriv->myfmt->setAttribute(pScrn, attribute, value);
++ struct v4l2_frequency freq;
++ memset(&freq, 0, sizeof(freq));
++ ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq);
++ freq.frequency = value;
++ if (ioctl(V4L_FD, VIDIOC_S_FREQUENCY, &freq) == -1)
++ xf86Msg(X_ERROR, "v4l: Error %d while setting frequency\n", errno);
++ else
++ ret = Success;
+ } else {
+- ret = BadValue;
++ for (i = 0; i < pPPriv->n_qctrl; i++)
++ if (pPPriv->XvV4LCtrl[i].xv == attribute)
++ break;
++ if (i == pPPriv->n_qctrl) {
++ /* not mine -> pass to yuv scaler driver */
++ if (0 != pPPriv->yuv_format && pPPriv->myfmt->setAttribute)
++ ret = pPPriv->myfmt->setAttribute(pScrn, attribute, value);
++ else
++ ret = BadMatch;
++ goto err;
++ }
++ if (pPPriv->XvV4LCtrl[i].qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
++ goto err;
++ ctrl.id = pPPriv->XvV4LCtrl[i].qctrl.id;
++ ctrl.value = value;
++ if (ioctl(V4L_FD, VIDIOC_S_CTRL, &ctrl) != 1)
++ ret = Success;
+ }
+
++err:
+ V4lCloseDevice(pPPriv,pScrn);
+ return ret;
+ }
+
+ static int
+-V4lGetPortAttribute(ScrnInfoPtr pScrn,
++V4lGetPortAttribute(ScrnInfoPtr pScrn,
+ Atom attribute, INT32 *value, pointer data)
+ {
++ struct v4l2_control ctrl;
+ PortPrivPtr pPPriv = (PortPrivPtr) data;
+- int ret = Success;
++ int i, ret = BadValue;
+
+ if (V4lOpenDevice(pPPriv, pScrn))
+- return Success;
++ return Success;
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/GPA %d\n",
+- attribute));
++ (int)attribute));
+
+ if (-1 == V4L_FD) {
+- ret = Success;
++ ret = Success;
+ } else if (attribute == xvEncoding) {
+- *value = pPPriv->cenc;
+- } else if (attribute == xvBrightness ||
+- attribute == xvContrast ||
+- attribute == xvSaturation ||
+- attribute == xvHue) {
+- ioctl(V4L_FD,VIDIOCGPICT,&pPPriv->pict);
+- if (attribute == xvBrightness) *value = v4l_to_xv(pPPriv->pict.brightness);
+- if (attribute == xvContrast) *value = v4l_to_xv(pPPriv->pict.contrast);
+- if (attribute == xvSaturation) *value = v4l_to_xv(pPPriv->pict.colour);
+- if (attribute == xvHue) *value = v4l_to_xv(pPPriv->pict.hue);
+- } else if (attribute == xvMute ||
+- attribute == xvVolume) {
+- ioctl(V4L_FD,VIDIOCGAUDIO,&pPPriv->audio);
+- if (attribute == xvMute) {
+- *value = (pPPriv->audio.flags & VIDEO_AUDIO_MUTE) ? 1 : 0;
+- } else if (attribute == xvVolume) {
+- if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
+- *value = v4l_to_xv(pPPriv->audio.volume);
+- } else {
+- ret = BadValue;
+- }
++ *value = pPPriv->cenc;
++ ret = Success;
+ } else if (attribute == xvFreq) {
+- unsigned long freq;
+- ioctl(V4L_FD,VIDIOCGFREQ,&freq);
+- *value = freq;
+- } else if (0 != pPPriv->yuv_format &&
+- pPPriv->myfmt->getAttribute) {
+- /* not mine -> pass to yuv scaler driver */
+- ret = pPPriv->myfmt->getAttribute(pScrn, attribute, value);
++ struct v4l2_frequency freq;
++ memset(&freq, 0, sizeof(freq));
++ if (ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq) != -1) {
++ *value = freq.frequency;
++ ret = Success;
++ }
+ } else {
+- ret = BadValue;
++ for (i = 0; i < pPPriv->n_qctrl; i++)
++ if (pPPriv->XvV4LCtrl[i].xv == attribute)
++ break;
++ if (i == pPPriv->n_qctrl) {
++ /* not mine -> pass to yuv scaler driver */
++ if (0 != pPPriv->yuv_format && pPPriv->myfmt->getAttribute)
++ ret = pPPriv->myfmt->getAttribute(pScrn, attribute, value);
++ else
++ ret = BadMatch;
++ goto err;
++ }
++ if (pPPriv->XvV4LCtrl[i].qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
++ goto err;
++ ctrl.id = pPPriv->XvV4LCtrl[i].qctrl.id;
++ if (ioctl(V4L_FD, VIDIOC_G_CTRL, &ctrl) != -1) {
++ *value = ctrl.value;
++ ret = Success;
++ }
+ }
+-
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/GPA %d, %d\n",
+- attribute, *value));
++ (int)attribute, (int)*value));
+
++err:
+ V4lCloseDevice(pPPriv,pScrn);
+ return ret;
+ }
+@@ -673,15 +875,15 @@ V4lQueryBestSize(ScrnInfoPtr pScrn, Bool motion,
+ int maxy = pPPriv->enc[pPPriv->cenc].height;
+
+ if (0 != pPPriv->yuv_format) {
+- *p_w = pPPriv->myfmt->max_width;
+- *p_h = pPPriv->myfmt->max_height;
++ *p_w = pPPriv->myfmt->max_width;
++ *p_h = pPPriv->myfmt->max_height;
+ } else {
+- *p_w = (drw_w < maxx) ? drw_w : maxx;
+- *p_h = (drw_h < maxy) ? drw_h : maxy;
++ *p_w = (drw_w < maxx) ? drw_w : maxx;
++ *p_h = (drw_h < maxy) ? drw_h : maxy;
+ }
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/BS %d %dx%d %dx%d\n",
+- pPPriv->cenc,drw_w,drw_h,*p_w,*p_h));
++ pPPriv->cenc,drw_w,drw_h,*p_w,*p_h));
+ }
+
+ static const OptionInfoRec *
+@@ -693,132 +895,198 @@ V4LAvailableOptions(int chipid, int busid)
+ static void
+ V4LIdentify(int flags)
+ {
+- xf86Msg(X_INFO, "v4l driver for Video4Linux\n");
+-}
++ xf86Msg(X_INFO, "v4l driver for Video4Linux overlay mode (V4L2)\n");
++}
+
+ static char*
+ fixname(char *str)
+ {
+ int s,d;
+ for (s=0, d=0;; s++) {
+- if (str[s] == '-')
+- continue;
+- str[d++] = tolower(str[s]);
+- if (0 == str[s])
+- break;
++ if (str[s] == '-')
++ continue;
++ str[d++] = tolower(str[s]);
++ if (0 == str[s])
++ break;
+ }
+ return str;
+ }
+
+ static int
+-v4l_add_enc(XF86VideoEncodingPtr enc, int i,
+- char *norm, char *input, int width, int height, int n, int d)
++AddV4LEnc(XF86VideoEncodingPtr enc, int entry,
++ char *norm, char *input, int width, int height, int n, int d)
+ {
+- enc[i].id = i;
+- enc[i].name = xalloc(strlen(norm)+strlen(input)+2);
+- if (NULL == enc[i].name)
+- return -1;
+- enc[i].width = width;
+- enc[i].height = height;
+- enc[i].rate.numerator = n;
+- enc[i].rate.denominator = d;
+- sprintf(enc[i].name,"%s-%s",norm,fixname(input));
++ enc->id = entry;
++ enc->name = malloc(strlen(norm) + strlen(input) + 2);
++ if (!enc->name)
++ return -1;
++
++ enc->width = width;
++ enc->height = height;
++ enc->rate.numerator = n;
++ enc->rate.denominator = d * 2; /* Refresh rate is twice, due to interlace */
++ sprintf(enc->name,"%s-%s",norm,fixname(input));
++
++ xf86Msg(X_INFO, "v4l: adding input %s, %dx%d %d fps\n",
++ enc->name, enc->width, enc->height, (d + n - 1)/n);
++
+ return 0;
+ }
+
++static int
++V4LGetStd(PortPrivPtr p, int fd)
++{
++ struct v4l2_standard standard;
++ int entries = 0;
++
++ /*
++ * 128 is just an arbitrary large number. There aren't that many video stds
++ * The max value is there just to avoid an endless loop, if the driver is
++ * broken.
++ */
++ for (entries = 0; entries < 128; entries++) {
++ memset(&standard, 0, sizeof(standard));
++ standard.index = entries;
++ if (-1 == ioctl(fd,VIDIOC_ENUMSTD, &standard))
++ break;
++ p->standard = realloc(p->standard, sizeof(standard) * (entries + 1));
++ memcpy(&p->standard[entries], &standard, sizeof(standard));
++ }
++
++ /*
++ * Some webcam drivers don't implement VIDIOC_ENUMSTD. Fake it
++ * This is currently unused, as no webcam driver allows OVERLAY mode,
++ * but the code is here, in the case some webcam driver starts allowing
++ * overlay.
++ * FIXME: Webcam drivers may use VIDIOC_ENUM_FRAMESIZES and
++ * VIDIOC_ENUM_FRAMEINTERVALS ioctl's that may help to fine-tune
++ * their needs. Those ioctl's could be used here in order to better
++ * support webcams.
++ */
++ if (!entries) {
++ xf86Msg(X_INFO, "v4l: VIDIOC_ENUMSTD error %d.\n",errno);
++ p->standard = realloc(p->standard, sizeof(standard) * (entries + 1));
++ p->standard[0].id = V4L2_STD_ALL;
++ strcpy((char *)p->standard[0].name, "CAMERA");
++ p->standard[0].frameperiod.numerator = 1001;
++ p->standard[0].frameperiod.denominator = 300001;
++ p->standard[0].framelines = 480;
++ entries++;
++ }
++ return entries;
++}
++
+ static void
+-V4LBuildEncodings(PortPrivPtr p, int fd, int channels)
++V4LBuildEncodings(PortPrivPtr p, int fd)
+ {
+- static struct video_channel channel;
+- int i,entries,have_bttv,bttv_ver;
+-
+-#define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
+- have_bttv = 0;
+- if (-1 != ioctl(fd,BTTV_VERSION,&bttv_ver))
+- have_bttv = 1;
+-
+- entries = (have_bttv ? 7 : 3) * channels;
+- p->enc = xalloc(sizeof(XF86VideoEncodingRec) * entries);
+- if (NULL == p->enc)
+- goto fail;
+- memset(p->enc,0,sizeof(XF86VideoEncodingRec) * entries);
+- p->norm = xalloc(sizeof(int) * entries);
+- if (NULL == p->norm)
+- goto fail;
+- memset(p->norm,0,sizeof(int) * entries);
+- p->input = xalloc(sizeof(int) * entries);
+- if (NULL == p->input)
+- goto fail;
+- memset(p->input,0,sizeof(int) * entries);
++ unsigned int inp, std, num_std;
++
++ num_std = V4LGetStd(p, fd);
+
+ p->nenc = 0;
+- for (i = 0; i < channels; i++) {
+- channel.channel = i;
+- if (-1 == ioctl(fd,VIDIOCGCHAN,&channel)) {
+- perror("ioctl VIDIOCGCHAN");
+- continue;
+- }
+-
+- v4l_add_enc(p->enc, p->nenc,"PAL", channel.name, 768,576, 1,50);
+- p->norm[p->nenc] = VIDEO_MODE_PAL;
+- p->input[p->nenc] = i;
+- p->nenc++;
+-
+- v4l_add_enc(p->enc,p->nenc,"NTSC", channel.name, 640,480, 1001,60000);
+- p->norm[p->nenc] = VIDEO_MODE_NTSC;
+- p->input[p->nenc] = i;
+- p->nenc++;
+-
+- v4l_add_enc(p->enc,p->nenc,"SECAM",channel.name, 768,576, 1,50);
+- p->norm[p->nenc] = VIDEO_MODE_SECAM;
+- p->input[p->nenc] = i;
+- p->nenc++;
+-
+- if (have_bttv) {
+- /* workaround for a v4l design flaw: The v4l API knows just pal,
+- ntsc and secam. But there are a few more norms (pal versions
+- with a different timings used in south america for example).
+- The bttv driver can handle these too. */
+- if (0 != v4l_add_enc(p->enc,p->nenc,"PAL-Nc",channel.name,
+- 640, 576, 1,50))
+- goto fail;
+- p->norm[p->nenc] = 3;
+- p->input[p->nenc] = i;
+- p->nenc++;
+-
+- if (0 != v4l_add_enc(p->enc,p->nenc,"PAL-M",channel.name,
+- 640, 576, 1,50))
+- goto fail;
+- p->norm[p->nenc] = 4;
+- p->input[p->nenc] = i;
+- p->nenc++;
+-
+- if (0 != v4l_add_enc(p->enc, p->nenc,"PAL-N", channel.name,
+- 768,576, 1,50))
+- goto fail;
+- p->norm[p->nenc] = 5;
+- p->input[p->nenc] = i;
+- p->nenc++;
+-
+- if (0 != v4l_add_enc(p->enc,p->nenc,"NTSC-JP", channel.name,
+- 640,480, 1001,60000))
+- goto fail;
+- p->norm[p->nenc] = 6;
+- p->input[p->nenc] = i;
+- p->nenc++;
+- }
++
++ /*
++ * 256 is just an arbitrary large number. There aren't that many video
++ * inputs on any driver. The max value is there just to avoid an endless
++ * loop, if the driver is broken.
++ */
++ for (inp = 0; inp < 256; inp++) {
++ struct v4l2_input input;
++
++ memset(&input, 0, sizeof(input));
++ input.index = inp;
++ if (ioctl(fd, VIDIOC_ENUMINPUT, &input) == -1)
++ break;
++
++ for (std = 0; std < num_std; std++) {
++ int width, height;
++
++ /*
++ * Currently, this code is not reliable, due to driver
++ * non-compliance on both saa7134 and bttv. So, instead,
++ * just use the video standard information
++ */
++#if 0
++ struct v4l2_framebuffer fbuf;
++
++ /* Some webcam drivers will fail here, but that's OK */
++ ioctl(fd, VIDIOC_S_STD, &p->standard[std].id);
++
++ memset(&fbuf, 0, sizeof(fbuf));
++ if (ioctl(fd, VIDIOC_G_FBUF, &fbuf) == -1) {
++ xf86Msg(X_INFO, "v4l: Error %d: Can't get FBUF\n", errno);
++ return;
++ }
++ height = fbuf.fmt.height;
++ width = fbuf.fmt.width;
++
++ /*
++ * If the overlay method fails, get the resolution
++ * via checking V4L2_BUF_TYPE_VIDEO_CAPTURE
++ */
++ if (!height || !width) {
++ struct v4l2_format format;
++
++ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
++ if (ioctl(fd, VIDIOC_G_FMT, &format) == -1) {
++ /* Hmm... device doesn't support capture. */
++ height = p->standard[std].framelines;
++ if (height == 480)
++ width = 640;
++ else if (height == 576)
++ width = 768;
++ else
++ continue;
++ } else {
++ height = format.fmt.pix.height;
++ width = format.fmt.pix.width;
++ }
++ }
++#else
++ if (p->standard[std].id & V4L2_STD_525_60) {
++ height = 480;
++ width = 640;
++ } else {
++ height = 576;
++ width = 768;
++ }
++
++#endif
++ /* Fixup for some driver bug */
++ if ((p->standard[std].id & V4L2_STD_525_60) && (height == 576))
++ height = 480;
++
++ p->enc = realloc(p->enc, sizeof(XF86VideoEncodingRec) * (p->nenc + 1));
++ p->norm = realloc(p->norm, sizeof(int) * (p->nenc + 1));
++ p->input = realloc(p->input, sizeof(int) * (p->nenc + 1));
++ if (!p->enc || !p->norm || !p->input)
++ goto fail;
++ if (AddV4LEnc(&p->enc[p->nenc], p->nenc,
++ (char *)p->standard[std].name,
++ (char *)input.name, width, height,
++ p->standard[std].frameperiod.numerator,
++ p->standard[std].frameperiod.denominator))
++ goto fail;
++ p->norm[p->nenc] = p->standard[std].id;
++ p->input[p->nenc] = inp;
++ p->nenc++;
++ }
+ }
++
++ if (!p->nenc)
++ xf86Msg(X_ERROR, "v4l: couldn't detect any valid input/standard\n");
+ return;
+-
+- fail:
++
++fail:
++ xf86Msg(X_ERROR, "v4l: Fail to get standards: %d\n", errno);
+ if (p->input)
+- xfree(p->input);
++ free(p->input);
+ p->input = NULL;
+ if (p->norm)
+- xfree(p->norm);
++ free(p->norm);
+ p->norm = NULL;
+ if (p->enc)
+- xfree(p->enc);
++ free(p->enc);
+ p->enc = NULL;
+ p->nenc = 0;
+ }
+@@ -826,73 +1094,33 @@ V4LBuildEncodings(PortPrivPtr p, int fd, int channels)
+ /* add a attribute a list */
+ static void
+ v4l_add_attr(XF86AttributeRec **list, int *count,
+- const XF86AttributeRec *attr)
++ const XF86AttributeRec *attr)
+ {
+ XF86AttributeRec *oldlist = *list;
+ int i;
++ Atom gpa;
+
+ for (i = 0; i < *count; i++) {
+- if (0 == strcmp((*list)[i].name,attr->name)) {
+- DEBUG(xf86Msg(X_INFO, "v4l: skip dup attr %s\n",attr->name));
+- return;
+- }
++ if (0 == strcmp((*list)[i].name,attr->name)) {
++ DEBUG(xf86Msg(X_INFO, "v4l: skip dup attr %s\n",attr->name));
++ return;
++ }
+ }
+-
+- DEBUG(xf86Msg(X_INFO, "v4l: add attr %s\n",attr->name));
+- *list = xalloc((*count + 1) * sizeof(XF86AttributeRec));
++
++ *list = malloc((*count + 1) * sizeof(XF86AttributeRec));
+ if (NULL == *list) {
+- *count = 0;
+- return;
++ *count = 0;
++ return;
+ }
+ if (*count)
+- memcpy(*list, oldlist, *count * sizeof(XF86AttributeRec));
++ memcpy(*list, oldlist, *count * sizeof(XF86AttributeRec));
+ memcpy(*list + *count, attr, sizeof(XF86AttributeRec));
+- (*count)++;
+-}
+
+-/* setup yuv overlay + hw scaling: look if we find some common video
+- format which both v4l driver and the X-Server can handle */
+-static void v4l_check_yuv(ScrnInfoPtr pScrn, PortPrivPtr pPPriv,
+- char *dev, int fd)
+-{
+- static const struct {
+- unsigned int v4l_palette;
+- unsigned int v4l_depth;
+- unsigned int xv_id;
+- unsigned int xv_format;
+- } yuvlist[] = {
+- { VIDEO_PALETTE_YUV422, 16, 0x32595559, XvPacked },
+- { VIDEO_PALETTE_UYVY, 16, 0x59565955, XvPacked },
+- { 0 /* end of list */ },
+- };
+- ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+- int fmt,i;
++ gpa = MAKE_ATOM((*list)[*count].name);
++ xf86Msg(X_INFO, "v4l: add attr %s (Xv/GPA %d) (%d to %d)\n",
++ attr->name, (int)gpa, attr->min_value, attr->max_value);
+
+- pPPriv->format = xf86XVQueryOffscreenImages(pScreen,&pPPriv->nformat);
+- for (fmt = 0; yuvlist[fmt].v4l_palette != 0; fmt++) {
+- /* check v4l ... */
+- ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
+- pPPriv->pict.palette = yuvlist[fmt].v4l_palette;
+- pPPriv->pict.depth = yuvlist[fmt].v4l_depth;
+- if (-1 == ioctl(fd,VIDIOCSPICT,&pPPriv->pict))
+- continue;
+- ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
+- if (pPPriv->pict.palette != yuvlist[fmt].v4l_palette)
+- continue;
+- /* ... works, check available offscreen image formats now ... */
+- for (i = 0; i < pPPriv->nformat; i++) {
+- if (pPPriv->format[i].image->id == yuvlist[fmt].xv_id &&
+- pPPriv->format[i].image->format == yuvlist[fmt].xv_format) {
+- /* ... match found, good. */
+- pPPriv->yuv_format = yuvlist[fmt].v4l_palette;
+- pPPriv->myfmt = pPPriv->format+i;
+- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+- "v4l[%s]: using hw video scaling [%4.4s].\n",
+- dev,(char*)&(pPPriv->format[i].image->id));
+- return;
+- }
+- }
+- }
++ (*count)++;
+ }
+
+ static int
+@@ -904,118 +1132,114 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
+ char dev[18];
+ int fd,i,j,d;
+
+- DEBUG(xf86Msg(X_INFO, "v4l: init start\n"));
+-
+ for (i = 0, d = 0; d < MAX_V4L_DEVICES; d++) {
+- sprintf(dev, "/dev/video%d", d);
+- fd = open(dev, O_RDWR, 0);
+- if (fd == -1) {
+- sprintf(dev, "/dev/v4l/video%d", d);
+- fd = open(dev, O_RDWR, 0);
+- if (fd == -1)
+- break;
+- }
+- DEBUG(xf86Msg(X_INFO, "v4l: %s open ok\n",dev));
+-
+- /* our private data */
+- pPPriv = xalloc(sizeof(PortPrivRec));
+- if (!pPPriv)
+- return FALSE;
+- memset(pPPriv,0,sizeof(PortPrivRec));
+- pPPriv->nr = d;
+-
+- /* check device */
+- if (-1 == ioctl(fd,VIDIOCGCAP,&pPPriv->cap) ||
+- 0 == (pPPriv->cap.type & VID_TYPE_OVERLAY)) {
+- DEBUG(xf86Msg(X_INFO, "v4l: %s: no overlay support\n",dev));
+- xfree(pPPriv);
+- close(fd);
+- continue;
+- }
+- strncpy(V4L_NAME, dev, 16);
+- V4LBuildEncodings(pPPriv,fd,pPPriv->cap.channels);
+- if (NULL == pPPriv->enc)
+- return FALSE;
+- v4l_check_yuv(pScrn,pPPriv,dev,fd);
+-
+- /* alloc VideoAdaptorRec */
+- VAR = xrealloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
+- VAR[i] = xalloc(sizeof(XF86VideoAdaptorRec));
+- if (!VAR[i])
+- return FALSE;
+- memset(VAR[i],0,sizeof(XF86VideoAdaptorRec));
+-
+-
+- /* build attribute list */
+- for (j = 0; j < V4L_ATTR; j++) {
+- /* video attributes */
+- v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
+- &Attributes[j]);
+- }
+- if (0 == ioctl(fd,VIDIOCGAUDIO,&pPPriv->audio)) {
+- /* audio attributes */
+- if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
+- v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
+- &VolumeAttr);
+- if (pPPriv->audio.flags & VIDEO_AUDIO_MUTABLE)
+- v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
+- &MuteAttr);
+- }
+- if (pPPriv->cap.type & VID_TYPE_TUNER) {
+- /* tuner attributes */
+- v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
+- &FreqAttr);
+- }
+- if (0 != pPPriv->yuv_format) {
+- /* pass throuth scaler attributes */
+- for (j = 0; j < pPPriv->myfmt->num_attributes; j++) {
+- v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
+- pPPriv->myfmt->attributes+j);
+- }
+- }
+-
+-
+- /* hook in private data */
+- Private = xalloc(sizeof(DevUnion));
+- if (!Private)
+- return FALSE;
+- memset(Private,0,sizeof(DevUnion));
+- Private->ptr = (pointer)pPPriv;
+- VAR[i]->pPortPrivates = Private;
+- VAR[i]->nPorts = 1;
+-
+- /* init VideoAdaptorRec */
+- VAR[i]->type = XvInputMask | XvWindowMask | XvVideoMask;
+- VAR[i]->name = "video4linux";
+- VAR[i]->flags = VIDEO_INVERT_CLIPLIST;
+-
+- VAR[i]->PutVideo = V4lPutVideo;
+- VAR[i]->PutStill = V4lPutStill;
+- VAR[i]->StopVideo = V4lStopVideo;
+- VAR[i]->SetPortAttribute = V4lSetPortAttribute;
+- VAR[i]->GetPortAttribute = V4lGetPortAttribute;
+- VAR[i]->QueryBestSize = V4lQueryBestSize;
+-
+- VAR[i]->nEncodings = pPPriv->nenc;
+- VAR[i]->pEncodings = pPPriv->enc;
+- VAR[i]->nFormats =
+- sizeof(InputVideoFormats) / sizeof(InputVideoFormats[0]);
+- VAR[i]->pFormats = InputVideoFormats;
+-
+- if (fd != -1)
+- close(fd);
+- i++;
++ sprintf(dev, "/dev/video%d", d);
++ fd = open(dev, O_RDWR, 0);
++ if (fd == -1) {
++ sprintf(dev, "/dev/v4l/video%d", d);
++ fd = open(dev, O_RDWR, 0);
++ if (fd == -1)
++ break;
++ }
++ DEBUG(xf86Msg(X_INFO, "v4l: %s open ok\n",dev));
++
++ /* our private data */
++ pPPriv = malloc(sizeof(PortPrivRec));
++ if (!pPPriv)
++ return FALSE;
++ memset(pPPriv,0,sizeof(PortPrivRec));
++ pPPriv->nr = d;
++
++ /* check device capabilities */
++ memset(&pPPriv->cap, 0, sizeof(&pPPriv->cap));
++ if (-1 == ioctl(fd, VIDIOC_QUERYCAP, &pPPriv->cap) ||
++ 0 == (pPPriv->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY)) {
++ xf86Msg(X_ERROR, "v4l: %s: no overlay support\n",dev);
++ free(pPPriv);
++ close(fd);
++ continue;
++ }
++
++ if (v4l_check_yuv(pScrn, pPPriv, dev, fd) == FALSE) {
++ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
++ "Xv Overlay not supported. Can't use v4l driver\n");
++ free(pPPriv);
++ close(fd);
++ continue;
++ }
++
++ xf86Msg(X_INFO, "v4l: enabling overlay mode for %s.\n", dev);
++ strncpy(V4L_NAME, dev, 16);
++ V4LBuildEncodings(pPPriv, fd);
++ if (NULL == pPPriv->enc)
++ return FALSE;
++
++ /* alloc VideoAdaptorRec */
++ VAR = realloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
++ VAR[i] = malloc(sizeof(XF86VideoAdaptorRec));
++ if (!VAR[i])
++ return FALSE;
++ memset(VAR[i],0,sizeof(XF86VideoAdaptorRec));
++
++ /* build attribute list */
++ AddAllV4LControls(pPPriv, &VAR[i]->pAttributes, &VAR[i]->nAttributes, fd);
++
++ for (j = 0; j < V4L_ATTR; j++) {
++ /* Other video attributes */
++ v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
++ &Attributes[j]);
++ }
++ if (pPPriv->cap.capabilities & V4L2_CAP_TUNER) {
++ /* tuner attributes */
++ v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
++ &FreqAttr);
++ }
++
++ /* Initialize yuv_format */
++ if (0 != pPPriv->yuv_format) {
++ /* pass throuth scaler attributes */
++ for (j = 0; j < pPPriv->myfmt->num_attributes; j++) {
++ v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
++ pPPriv->myfmt->attributes+j);
++ }
++ }
++
++ DEBUG(xf86Msg(X_INFO, "v4l: saving config into driver data\n"));
++ /* hook in private data */
++ Private = malloc(sizeof(DevUnion));
++ if (!Private)
++ return FALSE;
++ memset(Private,0,sizeof(DevUnion));
++ Private->ptr = (pointer)pPPriv;
++ VAR[i]->pPortPrivates = Private;
++ VAR[i]->nPorts = 1;
++
++ /* init VideoAdaptorRec */
++ VAR[i]->type = XvInputMask | XvWindowMask | XvVideoMask;
++ VAR[i]->name = "video4linux";
++ VAR[i]->flags = VIDEO_INVERT_CLIPLIST;
++
++ VAR[i]->PutVideo = V4lPutVideo;
++ VAR[i]->PutStill = V4lPutStill;
++ VAR[i]->StopVideo = V4lStopVideo;
++ VAR[i]->SetPortAttribute = V4lSetPortAttribute;
++ VAR[i]->GetPortAttribute = V4lGetPortAttribute;
++ VAR[i]->QueryBestSize = V4lQueryBestSize;
++
++ VAR[i]->nEncodings = pPPriv->nenc;
++ VAR[i]->pEncodings = pPPriv->enc;
++ VAR[i]->nFormats = sizeof(InputVideoFormats) / sizeof(InputVideoFormats[0]);
++ VAR[i]->pFormats = InputVideoFormats;
++
++ if (fd != -1) {
++ DEBUG(xf86Msg(X_INFO, "v4l: %s init finished.\n",dev));
++ close(fd);
++ }
++ i++;
+ }
+
+ xvEncoding = MAKE_ATOM(XV_ENCODING);
+- xvHue = MAKE_ATOM(XV_HUE);
+- xvSaturation = MAKE_ATOM(XV_SATURATION);
+- xvBrightness = MAKE_ATOM(XV_BRIGHTNESS);
+- xvContrast = MAKE_ATOM(XV_CONTRAST);
+-
+ xvFreq = MAKE_ATOM(XV_FREQ);
+- xvMute = MAKE_ATOM(XV_MUTE);
+- xvVolume = MAKE_ATOM(XV_VOLUME);
+
+ DEBUG(xf86Msg(X_INFO, "v4l: init done, %d device(s) found\n",i));
+
+@@ -1024,10 +1248,43 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
+ }
+
+ static Bool
++V4LDetect(void)
++{
++ struct v4l2_capability cap;
++ int fd, d, n = 0;
++ char dev[18];
++
++ for (d = 0; d < MAX_V4L_DEVICES; d++) {
++ sprintf(dev, "/dev/video%d", d);
++ fd = open(dev, O_RDWR, 0);
++ if (fd == -1) {
++ sprintf(dev, "/dev/v4l/video%d", d);
++ fd = open(dev, O_RDWR, 0);
++ if (fd == -1)
++ break;
++ }
++ close (fd);
++ memset(&cap, 0, sizeof(cap));
++ if (!ioctl(fd, VIDIOC_QUERYCAP, &cap) &&
++ (cap.capabilities & V4L2_CAP_VIDEO_OVERLAY))
++ n++;
++ }
++ xf86Msg(X_INFO, "v4l: %d video adapters with overlay support detected\n", n);
++
++ return (n > 0) ? TRUE : FALSE;
++}
++
++static Bool
+ V4LProbe(DriverPtr drv, int flags)
+ {
+- if (flags & PROBE_DETECT)
+- return TRUE;
++ /*
++ * Don't try to register adapter at the detection phase, as Xv
++ * extensions won't be there
++ */
++ if (flags == PROBE_DETECT)
++ return V4LDetect();
++
++ DEBUG(xf86Msg(X_INFO, "v4l: Initiating device probe\n"));
+
+ xf86XVRegisterGenericAdaptorDriver(V4LInit);
+ drv->refCount++;
+diff --git a/src/videodev.h b/src/videodev.h
+deleted file mode 100644
+index 3c9a7d8..0000000
+--- a/src/videodev.h
++++ /dev/null
+@@ -1,254 +0,0 @@
+-#ifndef __LINUX_VIDEODEV_H
+-#define __LINUX_VIDEODEV_H
+-
+-/* Linux V4L API, Version 1
+- * videodev.h from v4l driver in Linux 2.2.3
+- *
+- * Used here with the explicit permission of the original author, Alan Cox.
+- * <alan@lxorguk.ukuu.org.uk>
+- */
+-
+-#include <X11/Xmd.h>
+-
+-#define VID_TYPE_CAPTURE 1 /* Can capture */
+-#define VID_TYPE_TUNER 2 /* Can tune */
+-#define VID_TYPE_TELETEXT 4 /* Does teletext */
+-#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
+-#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
+-#define VID_TYPE_CLIPPING 32 /* Can clip */
+-#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
+-#define VID_TYPE_SCALES 128 /* Scalable */
+-#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
+-#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
+-
+-struct video_capability
+-{
+- char name[32];
+- int type;
+- int channels; /* Num channels */
+- int audios; /* Num audio devices */
+- int maxwidth; /* Supported width */
+- int maxheight; /* And height */
+- int minwidth; /* Supported width */
+- int minheight; /* And height */
+-};
+-
+-
+-struct video_channel
+-{
+- int channel;
+- char name[32];
+- int tuners;
+- CARD32 flags;
+-#define VIDEO_VC_TUNER 1 /* Channel has a tuner */
+-#define VIDEO_VC_AUDIO 2 /* Channel has audio */
+- CARD16 type;
+-#define VIDEO_TYPE_TV 1
+-#define VIDEO_TYPE_CAMERA 2
+- CARD16 norm; /* Norm set by channel */
+-};
+-
+-struct video_tuner
+-{
+- int tuner;
+- char name[32];
+- unsigned long rangelow, rangehigh; /* Tuner range */
+- CARD32 flags;
+-#define VIDEO_TUNER_PAL 1
+-#define VIDEO_TUNER_NTSC 2
+-#define VIDEO_TUNER_SECAM 4
+-#define VIDEO_TUNER_LOW 8 /* Uses KHz not MHz */
+-#define VIDEO_TUNER_NORM 16 /* Tuner can set norm */
+-#define VIDEO_TUNER_STEREO_ON 128 /* Tuner is seeing stereo */
+- CARD16 mode; /* PAL/NTSC/SECAM/OTHER */
+-#define VIDEO_MODE_PAL 0
+-#define VIDEO_MODE_NTSC 1
+-#define VIDEO_MODE_SECAM 2
+-#define VIDEO_MODE_AUTO 3
+- CARD16 signal; /* Signal strength 16bit scale */
+-};
+-
+-struct video_picture
+-{
+- CARD16 brightness;
+- CARD16 hue;
+- CARD16 colour;
+- CARD16 contrast;
+- CARD16 whiteness; /* Black and white only */
+- CARD16 depth; /* Capture depth */
+- CARD16 palette; /* Palette in use */
+-#define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
+-#define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
+-#define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */
+-#define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */
+-#define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */
+-#define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */
+-#define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */
+-#define VIDEO_PALETTE_YUYV 8
+-#define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */
+-#define VIDEO_PALETTE_YUV420 10
+-#define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */
+-#define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */
+-#define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */
+-#define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */
+-#define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */
+-#define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */
+-#define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */
+-#define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */
+-};
+-
+-struct video_audio
+-{
+- int audio; /* Audio channel */
+- CARD16 volume; /* If settable */
+- CARD16 bass, treble;
+- CARD32 flags;
+-#define VIDEO_AUDIO_MUTE 1
+-#define VIDEO_AUDIO_MUTABLE 2
+-#define VIDEO_AUDIO_VOLUME 4
+-#define VIDEO_AUDIO_BASS 8
+-#define VIDEO_AUDIO_TREBLE 16
+- char name[16];
+-#define VIDEO_SOUND_MONO 1
+-#define VIDEO_SOUND_STEREO 2
+-#define VIDEO_SOUND_LANG1 4
+-#define VIDEO_SOUND_LANG2 8
+- CARD16 mode;
+- CARD16 balance; /* Stereo balance */
+- CARD16 step; /* Step actual volume uses */
+-};
+-
+-struct video_clip
+-{
+- INT32 x,y;
+- INT32 width, height;
+- struct video_clip *next; /* For user use/driver use only */
+-};
+-
+-struct video_window
+-{
+- CARD32 x,y; /* Position of window */
+- CARD32 width,height; /* Its size */
+- CARD32 chromakey;
+- CARD32 flags;
+- struct video_clip *clips; /* Set only */
+- int clipcount;
+-#define VIDEO_WINDOW_INTERLACE 1
+-#define VIDEO_CLIP_BITMAP -1
+-/* bitmap is 1024x625, a '1' bit represents a clipped pixel */
+-#define VIDEO_CLIPMAP_SIZE (128 * 625)
+-};
+-
+-struct video_capture
+-{
+- CARD32 x,y; /* Offsets into image */
+- CARD32 width, height; /* Area to capture */
+- CARD16 decimation; /* Decimation divder */
+- CARD16 flags; /* Flags for capture */
+-#define VIDEO_CAPTURE_ODD 0 /* Temporal */
+-#define VIDEO_CAPTURE_EVEN 1
+-};
+-
+-struct video_buffer
+-{
+- void *base;
+- int height,width;
+- int depth;
+- int bytesperline;
+-};
+-
+-struct video_mmap
+-{
+- unsigned int frame; /* Frame (0 - n) for double buffer */
+- int height,width;
+- unsigned int format; /* should be VIDEO_PALETTE_* */
+-};
+-
+-struct video_key
+-{
+- CARD8 key[8];
+- CARD32 flags;
+-};
+-
+-
+-#define VIDEO_MAX_FRAME 32
+-
+-struct video_mbuf
+-{
+- int size; /* Total memory to map */
+- int frames; /* Frames */
+- int offsets[VIDEO_MAX_FRAME];
+-};
+-
+-
+-#define VIDEO_NO_UNIT (-1)
+-
+-
+-struct video_unit
+-{
+- int video; /* Video minor */
+- int vbi; /* VBI minor */
+- int radio; /* Radio minor */
+- int audio; /* Audio minor */
+- int teletext; /* Teletext minor */
+-};
+-
+-#define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */
+-#define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */
+-#define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */
+-#define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */
+-#define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */
+-#define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */
+-#define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */
+-#define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */
+-#define VIDIOCGWIN _IOR('v',9, struct video_window) /* Set the video overlay window */
+-#define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
+-#define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */
+-#define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */
+-#define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */
+-#define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */
+-#define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */
+-#define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */
+-#define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */
+-#define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */
+-#define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */
+-#define VIDIOCGMBUF _IOR('v', 20, struct video_mbuf) /* Memory map buffer info */
+-#define VIDIOCGUNIT _IOR('v', 21, struct video_unit) /* Get attached units */
+-#define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get frame buffer */
+-#define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set frame buffer - root only */
+-
+-#define BASE_VIDIOCPRIVATE 192 /* 192-255 are private */
+-
+-
+-#define VID_HARDWARE_BT848 1
+-#define VID_HARDWARE_QCAM_BW 2
+-#define VID_HARDWARE_PMS 3
+-#define VID_HARDWARE_QCAM_C 4
+-#define VID_HARDWARE_PSEUDO 5
+-#define VID_HARDWARE_SAA5249 6
+-#define VID_HARDWARE_AZTECH 7
+-#define VID_HARDWARE_SF16MI 8
+-#define VID_HARDWARE_RTRACK 9
+-#define VID_HARDWARE_ZOLTRIX 10
+-#define VID_HARDWARE_SAA7146 11
+-#define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */
+-#define VID_HARDWARE_RTRACK2 13
+-#define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */
+-#define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */
+-#define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */
+-#define VID_HARDWARE_BROADWAY 17 /* Broadway project */
+-#define VID_HARDWARE_GEMTEK 18
+-#define VID_HARDWARE_TYPHOON 19
+-#define VID_HARDWARE_VINO 20 /* Reserved for SGI Indy Vino */
+-
+-/*
+- * Initialiser list
+- */
+-
+-struct video_init
+-{
+- char *name;
+- int (*init)(struct video_init *);
+-};
+-
+-#endif
+diff --git a/src/videodev2.h b/src/videodev2.h
+new file mode 100644
+index 0000000..bf6dde2
+--- /dev/null
++++ b/src/videodev2.h
+@@ -0,0 +1,1929 @@
++/*
++ * Video for Linux Two header file
++ *
++ * Copyright (C) 1999-2007 the contributors
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * Alternatively you can redistribute this file under the terms of the
++ * BSD license as stated below:
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in
++ * the documentation and/or other materials provided with the
++ * distribution.
++ * 3. The names of its contributors may not be used to endorse or promote
++ * products derived from this software without specific prior written
++ * permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
++ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
++ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
++ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
++ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
++ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ *
++ * Header file for v4l or V4L2 drivers and applications
++ * with public API.
++ * All kernel-specific stuff were moved to media/v4l2-dev.h, so
++ * no #if __KERNEL tests are allowed here
++ *
++ * See http://linuxtv.org for more info
++ *
++ * Author: Bill Dirks <bill@thedirks.org>
++ * Justin Schoeman
++ * Hans Verkuil <hverkuil@xs4all.nl>
++ * et al.
++ */
++#ifndef __LINUX_VIDEODEV2_H
++#define __LINUX_VIDEODEV2_H
++
++#include <linux/ioctl.h>
++#include <linux/types.h>
++#include <sys/time.h>
++
++/*
++ * Common stuff for both V4L1 and V4L2
++ * Moved from videodev.h
++ */
++#define VIDEO_MAX_FRAME 32
++#define VIDEO_MAX_PLANES 8
++
++/* These defines are V4L1 specific and should not be used with the V4L2 API!
++ They will be removed from this header in the future. */
++
++#define VID_TYPE_CAPTURE 1 /* Can capture */
++#define VID_TYPE_TUNER 2 /* Can tune */
++#define VID_TYPE_TELETEXT 4 /* Does teletext */
++#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
++#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
++#define VID_TYPE_CLIPPING 32 /* Can clip */
++#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
++#define VID_TYPE_SCALES 128 /* Scalable */
++#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
++#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
++#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
++#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
++#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
++#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
++
++/*
++ * M I S C E L L A N E O U S
++ */
++
++/* Four-character-code (FOURCC) */
++#define v4l2_fourcc(a, b, c, d)\
++ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
++
++/*
++ * E N U M S
++ */
++enum v4l2_field {
++ V4L2_FIELD_ANY = 0, /* driver can choose from none,
++ top, bottom, interlaced
++ depending on whatever it thinks
++ is approximate ... */
++ V4L2_FIELD_NONE = 1, /* this device has no fields ... */
++ V4L2_FIELD_TOP = 2, /* top field only */
++ V4L2_FIELD_BOTTOM = 3, /* bottom field only */
++ V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
++ V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one
++ buffer, top-bottom order */
++ V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */
++ V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into
++ separate buffers */
++ V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field
++ first and the top field is
++ transmitted first */
++ V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field
++ first and the bottom field is
++ transmitted first */
++};
++#define V4L2_FIELD_HAS_TOP(field) \
++ ((field) == V4L2_FIELD_TOP ||\
++ (field) == V4L2_FIELD_INTERLACED ||\
++ (field) == V4L2_FIELD_INTERLACED_TB ||\
++ (field) == V4L2_FIELD_INTERLACED_BT ||\
++ (field) == V4L2_FIELD_SEQ_TB ||\
++ (field) == V4L2_FIELD_SEQ_BT)
++#define V4L2_FIELD_HAS_BOTTOM(field) \
++ ((field) == V4L2_FIELD_BOTTOM ||\
++ (field) == V4L2_FIELD_INTERLACED ||\
++ (field) == V4L2_FIELD_INTERLACED_TB ||\
++ (field) == V4L2_FIELD_INTERLACED_BT ||\
++ (field) == V4L2_FIELD_SEQ_TB ||\
++ (field) == V4L2_FIELD_SEQ_BT)
++#define V4L2_FIELD_HAS_BOTH(field) \
++ ((field) == V4L2_FIELD_INTERLACED ||\
++ (field) == V4L2_FIELD_INTERLACED_TB ||\
++ (field) == V4L2_FIELD_INTERLACED_BT ||\
++ (field) == V4L2_FIELD_SEQ_TB ||\
++ (field) == V4L2_FIELD_SEQ_BT)
++
++enum v4l2_buf_type {
++ V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
++ V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
++ V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
++ V4L2_BUF_TYPE_VBI_CAPTURE = 4,
++ V4L2_BUF_TYPE_VBI_OUTPUT = 5,
++ V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
++ V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
++#if 1
++ /* Experimental */
++ V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
++#endif
++ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
++ V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
++ V4L2_BUF_TYPE_PRIVATE = 0x80,
++};
++
++#define V4L2_TYPE_IS_MULTIPLANAR(type) \
++ ((type) == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE \
++ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
++
++#define V4L2_TYPE_IS_OUTPUT(type) \
++ ((type) == V4L2_BUF_TYPE_VIDEO_OUTPUT \
++ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE \
++ || (type) == V4L2_BUF_TYPE_VIDEO_OVERLAY \
++ || (type) == V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY \
++ || (type) == V4L2_BUF_TYPE_VBI_OUTPUT \
++ || (type) == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
++
++enum v4l2_tuner_type {
++ V4L2_TUNER_RADIO = 1,
++ V4L2_TUNER_ANALOG_TV = 2,
++ V4L2_TUNER_DIGITAL_TV = 3,
++};
++
++enum v4l2_memory {
++ V4L2_MEMORY_MMAP = 1,
++ V4L2_MEMORY_USERPTR = 2,
++ V4L2_MEMORY_OVERLAY = 3,
++};
++
++/* see also http://vektor.theorem.ca/graphics/ycbcr/ */
++enum v4l2_colorspace {
++ /* ITU-R 601 -- broadcast NTSC/PAL */
++ V4L2_COLORSPACE_SMPTE170M = 1,
++
++ /* 1125-Line (US) HDTV */
++ V4L2_COLORSPACE_SMPTE240M = 2,
++
++ /* HD and modern captures. */
++ V4L2_COLORSPACE_REC709 = 3,
++
++ /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
++ V4L2_COLORSPACE_BT878 = 4,
++
++ /* These should be useful. Assume 601 extents. */
++ V4L2_COLORSPACE_470_SYSTEM_M = 5,
++ V4L2_COLORSPACE_470_SYSTEM_BG = 6,
++
++ /* I know there will be cameras that send this. So, this is
++ * unspecified chromaticities and full 0-255 on each of the
++ * Y'CbCr components
++ */
++ V4L2_COLORSPACE_JPEG = 7,
++
++ /* For RGB colourspaces, this is probably a good start. */
++ V4L2_COLORSPACE_SRGB = 8,
++};
++
++enum v4l2_priority {
++ V4L2_PRIORITY_UNSET = 0, /* not initialized */
++ V4L2_PRIORITY_BACKGROUND = 1,
++ V4L2_PRIORITY_INTERACTIVE = 2,
++ V4L2_PRIORITY_RECORD = 3,
++ V4L2_PRIORITY_DEFAULT = V4L2_PRIORITY_INTERACTIVE,
++};
++
++struct v4l2_rect {
++ __s32 left;
++ __s32 top;
++ __s32 width;
++ __s32 height;
++};
++
++struct v4l2_fract {
++ __u32 numerator;
++ __u32 denominator;
++};
++
++/*
++ * D R I V E R C A P A B I L I T I E S
++ */
++struct v4l2_capability {
++ __u8 driver[16]; /* i.e. "bttv" */
++ __u8 card[32]; /* i.e. "Hauppauge WinTV" */
++ __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
++ __u32 version; /* should use KERNEL_VERSION() */
++ __u32 capabilities; /* Device capabilities */
++ __u32 reserved[4];
++};
++
++/* Values for 'capabilities' field */
++#define V4L2_CAP_VIDEO_CAPTURE 0x00000001 /* Is a video capture device */
++#define V4L2_CAP_VIDEO_OUTPUT 0x00000002 /* Is a video output device */
++#define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */
++#define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */
++#define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */
++#define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */
++#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */
++#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
++#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */
++#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
++#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */
++
++/* Is a video capture device that supports multiplanar formats */
++#define V4L2_CAP_VIDEO_CAPTURE_MPLANE 0x00001000
++/* Is a video output device that supports multiplanar formats */
++#define V4L2_CAP_VIDEO_OUTPUT_MPLANE 0x00002000
++
++#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
++#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
++#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
++#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */
++
++#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
++#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
++#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
++
++/*
++ * V I D E O I M A G E F O R M A T
++ */
++struct v4l2_pix_format {
++ __u32 width;
++ __u32 height;
++ __u32 pixelformat;
++ enum v4l2_field field;
++ __u32 bytesperline; /* for padding, zero if unused */
++ __u32 sizeimage;
++ enum v4l2_colorspace colorspace;
++ __u32 priv; /* private data, depends on pixelformat */
++};
++
++/* Pixel format FOURCC depth Description */
++
++/* RGB formats */
++#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */
++#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */
++#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */
++#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */
++#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */
++#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */
++#define V4L2_PIX_FMT_BGR666 v4l2_fourcc('B', 'G', 'R', 'H') /* 18 BGR-6-6-6 */
++#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
++#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
++#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
++#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */
++
++/* Grey formats */
++#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
++#define V4L2_PIX_FMT_Y4 v4l2_fourcc('Y', '0', '4', ' ') /* 4 Greyscale */
++#define V4L2_PIX_FMT_Y6 v4l2_fourcc('Y', '0', '6', ' ') /* 6 Greyscale */
++#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ') /* 10 Greyscale */
++#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
++
++/* Palette formats */
++#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
++
++/* Luminance+Chrominance formats */
++#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */
++#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
++#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
++#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
++#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
++#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
++#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */
++#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
++#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
++#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
++#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */
++#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
++#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
++#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
++#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
++#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
++#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
++#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
++
++/* two planes -- one Y, one Cr + Cb interleaved */
++#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
++#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
++#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
++#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
++
++/* two non contiguous planes - one Y, one Cr + Cb interleaved */
++#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
++#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */
++
++/* three non contiguous planes - Y, Cb, Cr */
++#define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */
++
++/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
++#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
++#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
++#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
++#define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R', 'G', 'G', 'B') /* 8 RGRG.. GBGB.. */
++#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0') /* 10 BGBG.. GRGR.. */
++#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10 GBGB.. RGRG.. */
++#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10 GRGR.. BGBG.. */
++#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10 RGRG.. GBGB.. */
++ /* 10bit raw bayer DPCM compressed to 8 bits */
++#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
++ /*
++ * 10bit raw bayer, expanded to 16 bits
++ * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
++ */
++#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
++
++/* compressed formats */
++#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
++#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */
++#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */
++#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */
++
++/* Vendor-specific formats */
++#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
++#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
++#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */
++#define V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0') /* SN9C20x YUV 4:2:0 */
++#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */
++#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */
++#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */
++#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */
++#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */
++#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */
++#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */
++#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */
++#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */
++#define V4L2_PIX_FMT_SN9C2028 v4l2_fourcc('S', 'O', 'N', 'X') /* compressed GBRG bayer */
++#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */
++#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */
++#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */
++#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */
++#define V4L2_PIX_FMT_STV0680 v4l2_fourcc('S', '6', '8', '0') /* stv0680 bayer */
++#define V4L2_PIX_FMT_TM6000 v4l2_fourcc('T', 'M', '6', '0') /* tm5600/tm60x0 */
++#define V4L2_PIX_FMT_CIT_YYVYUY v4l2_fourcc('C', 'I', 'T', 'V') /* one line of Y then 1 line of VYUY */
++#define V4L2_PIX_FMT_KONICA420 v4l2_fourcc('K', 'O', 'N', 'I') /* YUV420 planar in blocks of 256 pixels */
++
++/*
++ * F O R M A T E N U M E R A T I O N
++ */
++struct v4l2_fmtdesc {
++ __u32 index; /* Format number */
++ enum v4l2_buf_type type; /* buffer type */
++ __u32 flags;
++ __u8 description[32]; /* Description string */
++ __u32 pixelformat; /* Format fourcc */
++ __u32 reserved[4];
++};
++
++#define V4L2_FMT_FLAG_COMPRESSED 0x0001
++#define V4L2_FMT_FLAG_EMULATED 0x0002
++
++#if 1
++ /* Experimental Frame Size and frame rate enumeration */
++/*
++ * F R A M E S I Z E E N U M E R A T I O N
++ */
++enum v4l2_frmsizetypes {
++ V4L2_FRMSIZE_TYPE_DISCRETE = 1,
++ V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
++ V4L2_FRMSIZE_TYPE_STEPWISE = 3,
++};
++
++struct v4l2_frmsize_discrete {
++ __u32 width; /* Frame width [pixel] */
++ __u32 height; /* Frame height [pixel] */
++};
++
++struct v4l2_frmsize_stepwise {
++ __u32 min_width; /* Minimum frame width [pixel] */
++ __u32 max_width; /* Maximum frame width [pixel] */
++ __u32 step_width; /* Frame width step size [pixel] */
++ __u32 min_height; /* Minimum frame height [pixel] */
++ __u32 max_height; /* Maximum frame height [pixel] */
++ __u32 step_height; /* Frame height step size [pixel] */
++};
++
++struct v4l2_frmsizeenum {
++ __u32 index; /* Frame size number */
++ __u32 pixel_format; /* Pixel format */
++ __u32 type; /* Frame size type the device supports. */
++
++ union { /* Frame size */
++ struct v4l2_frmsize_discrete discrete;
++ struct v4l2_frmsize_stepwise stepwise;
++ };
++
++ __u32 reserved[2]; /* Reserved space for future use */
++};
++
++/*
++ * F R A M E R A T E E N U M E R A T I O N
++ */
++enum v4l2_frmivaltypes {
++ V4L2_FRMIVAL_TYPE_DISCRETE = 1,
++ V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
++ V4L2_FRMIVAL_TYPE_STEPWISE = 3,
++};
++
++struct v4l2_frmival_stepwise {
++ struct v4l2_fract min; /* Minimum frame interval [s] */
++ struct v4l2_fract max; /* Maximum frame interval [s] */
++ struct v4l2_fract step; /* Frame interval step size [s] */
++};
++
++struct v4l2_frmivalenum {
++ __u32 index; /* Frame format index */
++ __u32 pixel_format; /* Pixel format */
++ __u32 width; /* Frame width */
++ __u32 height; /* Frame height */
++ __u32 type; /* Frame interval type the device supports. */
++
++ union { /* Frame interval */
++ struct v4l2_fract discrete;
++ struct v4l2_frmival_stepwise stepwise;
++ };
++
++ __u32 reserved[2]; /* Reserved space for future use */
++};
++#endif
++
++/*
++ * T I M E C O D E
++ */
++struct v4l2_timecode {
++ __u32 type;
++ __u32 flags;
++ __u8 frames;
++ __u8 seconds;
++ __u8 minutes;
++ __u8 hours;
++ __u8 userbits[4];
++};
++
++/* Type */
++#define V4L2_TC_TYPE_24FPS 1
++#define V4L2_TC_TYPE_25FPS 2
++#define V4L2_TC_TYPE_30FPS 3
++#define V4L2_TC_TYPE_50FPS 4
++#define V4L2_TC_TYPE_60FPS 5
++
++/* Flags */
++#define V4L2_TC_FLAG_DROPFRAME 0x0001 /* "drop-frame" mode */
++#define V4L2_TC_FLAG_COLORFRAME 0x0002
++#define V4L2_TC_USERBITS_field 0x000C
++#define V4L2_TC_USERBITS_USERDEFINED 0x0000
++#define V4L2_TC_USERBITS_8BITCHARS 0x0008
++/* The above is based on SMPTE timecodes */
++
++struct v4l2_jpegcompression {
++ int quality;
++
++ int APPn; /* Number of APP segment to be written,
++ * must be 0..15 */
++ int APP_len; /* Length of data in JPEG APPn segment */
++ char APP_data[60]; /* Data in the JPEG APPn segment. */
++
++ int COM_len; /* Length of data in JPEG COM segment */
++ char COM_data[60]; /* Data in JPEG COM segment */
++
++ __u32 jpeg_markers; /* Which markers should go into the JPEG
++ * output. Unless you exactly know what
++ * you do, leave them untouched.
++ * Inluding less markers will make the
++ * resulting code smaller, but there will
++ * be fewer applications which can read it.
++ * The presence of the APP and COM marker
++ * is influenced by APP_len and COM_len
++ * ONLY, not by this property! */
++
++#define V4L2_JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */
++#define V4L2_JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */
++#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
++#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */
++#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will
++ * allways use APP0 */
++};
++
++/*
++ * M E M O R Y - M A P P I N G B U F F E R S
++ */
++struct v4l2_requestbuffers {
++ __u32 count;
++ enum v4l2_buf_type type;
++ enum v4l2_memory memory;
++ __u32 reserved[2];
++};
++
++/**
++ * struct v4l2_plane - plane info for multi-planar buffers
++ * @bytesused: number of bytes occupied by data in the plane (payload)
++ * @length: size of this plane (NOT the payload) in bytes
++ * @mem_offset: when memory in the associated struct v4l2_buffer is
++ * V4L2_MEMORY_MMAP, equals the offset from the start of
++ * the device memory for this plane (or is a "cookie" that
++ * should be passed to mmap() called on the video node)
++ * @userptr: when memory is V4L2_MEMORY_USERPTR, a userspace pointer
++ * pointing to this plane
++ * @data_offset: offset in the plane to the start of data; usually 0,
++ * unless there is a header in front of the data
++ *
++ * Multi-planar buffers consist of one or more planes, e.g. an YCbCr buffer
++ * with two planes can have one plane for Y, and another for interleaved CbCr
++ * components. Each plane can reside in a separate memory buffer, or even in
++ * a completely separate memory node (e.g. in embedded devices).
++ */
++struct v4l2_plane {
++ __u32 bytesused;
++ __u32 length;
++ union {
++ __u32 mem_offset;
++ unsigned long userptr;
++ } m;
++ __u32 data_offset;
++ __u32 reserved[11];
++};
++
++/**
++ * struct v4l2_buffer - video buffer info
++ * @index: id number of the buffer
++ * @type: buffer type (type == *_MPLANE for multiplanar buffers)
++ * @bytesused: number of bytes occupied by data in the buffer (payload);
++ * unused (set to 0) for multiplanar buffers
++ * @flags: buffer informational flags
++ * @field: field order of the image in the buffer
++ * @timestamp: frame timestamp
++ * @timecode: frame timecode
++ * @sequence: sequence count of this frame
++ * @memory: the method, in which the actual video data is passed
++ * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
++ * offset from the start of the device memory for this plane,
++ * (or a "cookie" that should be passed to mmap() as offset)
++ * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
++ * a userspace pointer pointing to this buffer
++ * @planes: for multiplanar buffers; userspace pointer to the array of plane
++ * info structs for this buffer
++ * @length: size in bytes of the buffer (NOT its payload) for single-plane
++ * buffers (when type != *_MPLANE); number of elements in the
++ * planes array for multi-plane buffers
++ * @input: input number from which the video data has has been captured
++ *
++ * Contains data exchanged by application and driver using one of the Streaming
++ * I/O methods.
++ */
++struct v4l2_buffer {
++ __u32 index;
++ enum v4l2_buf_type type;
++ __u32 bytesused;
++ __u32 flags;
++ enum v4l2_field field;
++ struct timeval timestamp;
++ struct v4l2_timecode timecode;
++ __u32 sequence;
++
++ /* memory location */
++ enum v4l2_memory memory;
++ union {
++ __u32 offset;
++ unsigned long userptr;
++ struct v4l2_plane *planes;
++ } m;
++ __u32 length;
++ __u32 input;
++ __u32 reserved;
++};
++
++/* Flags for 'flags' field */
++#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */
++#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */
++#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */
++#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */
++#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */
++#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */
++/* Buffer is ready, but the data contained within is corrupted. */
++#define V4L2_BUF_FLAG_ERROR 0x0040
++#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */
++#define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */
++
++/*
++ * O V E R L A Y P R E V I E W
++ */
++struct v4l2_framebuffer {
++ __u32 capability;
++ __u32 flags;
++/* FIXME: in theory we should pass something like PCI device + memory
++ * region + offset instead of some physical address */
++ void *base;
++ struct v4l2_pix_format fmt;
++};
++/* Flags for the 'capability' field. Read only */
++#define V4L2_FBUF_CAP_EXTERNOVERLAY 0x0001
++#define V4L2_FBUF_CAP_CHROMAKEY 0x0002
++#define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004
++#define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008
++#define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010
++#define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020
++#define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040
++#define V4L2_FBUF_CAP_SRC_CHROMAKEY 0x0080
++/* Flags for the 'flags' field. */
++#define V4L2_FBUF_FLAG_PRIMARY 0x0001
++#define V4L2_FBUF_FLAG_OVERLAY 0x0002
++#define V4L2_FBUF_FLAG_CHROMAKEY 0x0004
++#define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008
++#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
++#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
++#define V4L2_FBUF_FLAG_SRC_CHROMAKEY 0x0040
++
++struct v4l2_clip {
++ struct v4l2_rect c;
++ struct v4l2_clip *next;
++};
++
++struct v4l2_window {
++ struct v4l2_rect w;
++ enum v4l2_field field;
++ __u32 chromakey;
++ struct v4l2_clip *clips;
++ __u32 clipcount;
++ void *bitmap;
++ __u8 global_alpha;
++};
++
++/*
++ * C A P T U R E P A R A M E T E R S
++ */
++struct v4l2_captureparm {
++ __u32 capability; /* Supported modes */
++ __u32 capturemode; /* Current mode */
++ struct v4l2_fract timeperframe; /* Time per frame in .1us units */
++ __u32 extendedmode; /* Driver-specific extensions */
++ __u32 readbuffers; /* # of buffers for read */
++ __u32 reserved[4];
++};
++
++/* Flags for 'capability' and 'capturemode' fields */
++#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
++#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
++
++struct v4l2_outputparm {
++ __u32 capability; /* Supported modes */
++ __u32 outputmode; /* Current mode */
++ struct v4l2_fract timeperframe; /* Time per frame in seconds */
++ __u32 extendedmode; /* Driver-specific extensions */
++ __u32 writebuffers; /* # of buffers for write */
++ __u32 reserved[4];
++};
++
++/*
++ * I N P U T I M A G E C R O P P I N G
++ */
++struct v4l2_cropcap {
++ enum v4l2_buf_type type;
++ struct v4l2_rect bounds;
++ struct v4l2_rect defrect;
++ struct v4l2_fract pixelaspect;
++};
++
++struct v4l2_crop {
++ enum v4l2_buf_type type;
++ struct v4l2_rect c;
++};
++
++/*
++ * A N A L O G V I D E O S T A N D A R D
++ */
++
++typedef __u64 v4l2_std_id;
++
++/* one bit for each */
++#define V4L2_STD_PAL_B ((v4l2_std_id)0x00000001)
++#define V4L2_STD_PAL_B1 ((v4l2_std_id)0x00000002)
++#define V4L2_STD_PAL_G ((v4l2_std_id)0x00000004)
++#define V4L2_STD_PAL_H ((v4l2_std_id)0x00000008)
++#define V4L2_STD_PAL_I ((v4l2_std_id)0x00000010)
++#define V4L2_STD_PAL_D ((v4l2_std_id)0x00000020)
++#define V4L2_STD_PAL_D1 ((v4l2_std_id)0x00000040)
++#define V4L2_STD_PAL_K ((v4l2_std_id)0x00000080)
++
++#define V4L2_STD_PAL_M ((v4l2_std_id)0x00000100)
++#define V4L2_STD_PAL_N ((v4l2_std_id)0x00000200)
++#define V4L2_STD_PAL_Nc ((v4l2_std_id)0x00000400)
++#define V4L2_STD_PAL_60 ((v4l2_std_id)0x00000800)
++
++#define V4L2_STD_NTSC_M ((v4l2_std_id)0x00001000)
++#define V4L2_STD_NTSC_M_JP ((v4l2_std_id)0x00002000)
++#define V4L2_STD_NTSC_443 ((v4l2_std_id)0x00004000)
++#define V4L2_STD_NTSC_M_KR ((v4l2_std_id)0x00008000)
++
++#define V4L2_STD_SECAM_B ((v4l2_std_id)0x00010000)
++#define V4L2_STD_SECAM_D ((v4l2_std_id)0x00020000)
++#define V4L2_STD_SECAM_G ((v4l2_std_id)0x00040000)
++#define V4L2_STD_SECAM_H ((v4l2_std_id)0x00080000)
++#define V4L2_STD_SECAM_K ((v4l2_std_id)0x00100000)
++#define V4L2_STD_SECAM_K1 ((v4l2_std_id)0x00200000)
++#define V4L2_STD_SECAM_L ((v4l2_std_id)0x00400000)
++#define V4L2_STD_SECAM_LC ((v4l2_std_id)0x00800000)
++
++/* ATSC/HDTV */
++#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)
++#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)
++
++/* FIXME:
++ Although std_id is 64 bits, there is an issue on PPC32 architecture that
++ makes switch(__u64) to break. So, there's a hack on v4l2-common.c rounding
++ this value to 32 bits.
++ As, currently, the max value is for V4L2_STD_ATSC_16_VSB (30 bits wide),
++ it should work fine. However, if needed to add more than two standards,
++ v4l2-common.c should be fixed.
++ */
++
++/* some merged standards */
++#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)
++#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B)
++#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H)
++#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK)
++
++/* some common needed stuff */
++#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\
++ V4L2_STD_PAL_B1 |\
++ V4L2_STD_PAL_G)
++#define V4L2_STD_PAL_DK (V4L2_STD_PAL_D |\
++ V4L2_STD_PAL_D1 |\
++ V4L2_STD_PAL_K)
++#define V4L2_STD_PAL (V4L2_STD_PAL_BG |\
++ V4L2_STD_PAL_DK |\
++ V4L2_STD_PAL_H |\
++ V4L2_STD_PAL_I)
++#define V4L2_STD_NTSC (V4L2_STD_NTSC_M |\
++ V4L2_STD_NTSC_M_JP |\
++ V4L2_STD_NTSC_M_KR)
++#define V4L2_STD_SECAM_DK (V4L2_STD_SECAM_D |\
++ V4L2_STD_SECAM_K |\
++ V4L2_STD_SECAM_K1)
++#define V4L2_STD_SECAM (V4L2_STD_SECAM_B |\
++ V4L2_STD_SECAM_G |\
++ V4L2_STD_SECAM_H |\
++ V4L2_STD_SECAM_DK |\
++ V4L2_STD_SECAM_L |\
++ V4L2_STD_SECAM_LC)
++
++#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\
++ V4L2_STD_PAL_60 |\
++ V4L2_STD_NTSC |\
++ V4L2_STD_NTSC_443)
++#define V4L2_STD_625_50 (V4L2_STD_PAL |\
++ V4L2_STD_PAL_N |\
++ V4L2_STD_PAL_Nc |\
++ V4L2_STD_SECAM)
++#define V4L2_STD_ATSC (V4L2_STD_ATSC_8_VSB |\
++ V4L2_STD_ATSC_16_VSB)
++
++#define V4L2_STD_UNKNOWN 0
++#define V4L2_STD_ALL (V4L2_STD_525_60 |\
++ V4L2_STD_625_50)
++
++struct v4l2_standard {
++ __u32 index;
++ v4l2_std_id id;
++ __u8 name[24];
++ struct v4l2_fract frameperiod; /* Frames, not fields */
++ __u32 framelines;
++ __u32 reserved[4];
++};
++
++/*
++ * V I D E O T I M I N G S D V P R E S E T
++ */
++struct v4l2_dv_preset {
++ __u32 preset;
++ __u32 reserved[4];
++};
++
++/*
++ * D V P R E S E T S E N U M E R A T I O N
++ */
++struct v4l2_dv_enum_preset {
++ __u32 index;
++ __u32 preset;
++ __u8 name[32]; /* Name of the preset timing */
++ __u32 width;
++ __u32 height;
++ __u32 reserved[4];
++};
++
++/*
++ * D V P R E S E T V A L U E S
++ */
++#define V4L2_DV_INVALID 0
++#define V4L2_DV_480P59_94 1 /* BT.1362 */
++#define V4L2_DV_576P50 2 /* BT.1362 */
++#define V4L2_DV_720P24 3 /* SMPTE 296M */
++#define V4L2_DV_720P25 4 /* SMPTE 296M */
++#define V4L2_DV_720P30 5 /* SMPTE 296M */
++#define V4L2_DV_720P50 6 /* SMPTE 296M */
++#define V4L2_DV_720P59_94 7 /* SMPTE 274M */
++#define V4L2_DV_720P60 8 /* SMPTE 274M/296M */
++#define V4L2_DV_1080I29_97 9 /* BT.1120/ SMPTE 274M */
++#define V4L2_DV_1080I30 10 /* BT.1120/ SMPTE 274M */
++#define V4L2_DV_1080I25 11 /* BT.1120 */
++#define V4L2_DV_1080I50 12 /* SMPTE 296M */
++#define V4L2_DV_1080I60 13 /* SMPTE 296M */
++#define V4L2_DV_1080P24 14 /* SMPTE 296M */
++#define V4L2_DV_1080P25 15 /* SMPTE 296M */
++#define V4L2_DV_1080P30 16 /* SMPTE 296M */
++#define V4L2_DV_1080P50 17 /* BT.1120 */
++#define V4L2_DV_1080P60 18 /* BT.1120 */
++
++/*
++ * D V B T T I M I N G S
++ */
++
++/* BT.656/BT.1120 timing data */
++struct v4l2_bt_timings {
++ __u32 width; /* width in pixels */
++ __u32 height; /* height in lines */
++ __u32 interlaced; /* Interlaced or progressive */
++ __u32 polarities; /* Positive or negative polarity */
++ __u64 pixelclock; /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
++ __u32 hfrontporch; /* Horizpontal front porch in pixels */
++ __u32 hsync; /* Horizontal Sync length in pixels */
++ __u32 hbackporch; /* Horizontal back porch in pixels */
++ __u32 vfrontporch; /* Vertical front porch in pixels */
++ __u32 vsync; /* Vertical Sync length in lines */
++ __u32 vbackporch; /* Vertical back porch in lines */
++ __u32 il_vfrontporch; /* Vertical front porch for bottom field of
++ * interlaced field formats
++ */
++ __u32 il_vsync; /* Vertical sync length for bottom field of
++ * interlaced field formats
++ */
++ __u32 il_vbackporch; /* Vertical back porch for bottom field of
++ * interlaced field formats
++ */
++ __u32 reserved[16];
++} __attribute__ ((packed));
++
++/* Interlaced or progressive format */
++#define V4L2_DV_PROGRESSIVE 0
++#define V4L2_DV_INTERLACED 1
++
++/* Polarities. If bit is not set, it is assumed to be negative polarity */
++#define V4L2_DV_VSYNC_POS_POL 0x00000001
++#define V4L2_DV_HSYNC_POS_POL 0x00000002
++
++
++/* DV timings */
++struct v4l2_dv_timings {
++ __u32 type;
++ union {
++ struct v4l2_bt_timings bt;
++ __u32 reserved[32];
++ };
++} __attribute__ ((packed));
++
++/* Values for the type field */
++#define V4L2_DV_BT_656_1120 0 /* BT.656/1120 timing type */
++
++/*
++ * V I D E O I N P U T S
++ */
++struct v4l2_input {
++ __u32 index; /* Which input */
++ __u8 name[32]; /* Label */
++ __u32 type; /* Type of input */
++ __u32 audioset; /* Associated audios (bitfield) */
++ __u32 tuner; /* Associated tuner */
++ v4l2_std_id std;
++ __u32 status;
++ __u32 capabilities;
++ __u32 reserved[3];
++};
++
++/* Values for the 'type' field */
++#define V4L2_INPUT_TYPE_TUNER 1
++#define V4L2_INPUT_TYPE_CAMERA 2
++
++/* field 'status' - general */
++#define V4L2_IN_ST_NO_POWER 0x00000001 /* Attached device is off */
++#define V4L2_IN_ST_NO_SIGNAL 0x00000002
++#define V4L2_IN_ST_NO_COLOR 0x00000004
++
++/* field 'status' - sensor orientation */
++/* If sensor is mounted upside down set both bits */
++#define V4L2_IN_ST_HFLIP 0x00000010 /* Frames are flipped horizontally */
++#define V4L2_IN_ST_VFLIP 0x00000020 /* Frames are flipped vertically */
++
++/* field 'status' - analog */
++#define V4L2_IN_ST_NO_H_LOCK 0x00000100 /* No horizontal sync lock */
++#define V4L2_IN_ST_COLOR_KILL 0x00000200 /* Color killer is active */
++
++/* field 'status' - digital */
++#define V4L2_IN_ST_NO_SYNC 0x00010000 /* No synchronization lock */
++#define V4L2_IN_ST_NO_EQU 0x00020000 /* No equalizer lock */
++#define V4L2_IN_ST_NO_CARRIER 0x00040000 /* Carrier recovery failed */
++
++/* field 'status' - VCR and set-top box */
++#define V4L2_IN_ST_MACROVISION 0x01000000 /* Macrovision detected */
++#define V4L2_IN_ST_NO_ACCESS 0x02000000 /* Conditional access denied */
++#define V4L2_IN_ST_VTR 0x04000000 /* VTR time constant */
++
++/* capabilities flags */
++#define V4L2_IN_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
++#define V4L2_IN_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
++#define V4L2_IN_CAP_STD 0x00000004 /* Supports S_STD */
++
++/*
++ * V I D E O O U T P U T S
++ */
++struct v4l2_output {
++ __u32 index; /* Which output */
++ __u8 name[32]; /* Label */
++ __u32 type; /* Type of output */
++ __u32 audioset; /* Associated audios (bitfield) */
++ __u32 modulator; /* Associated modulator */
++ v4l2_std_id std;
++ __u32 capabilities;
++ __u32 reserved[3];
++};
++/* Values for the 'type' field */
++#define V4L2_OUTPUT_TYPE_MODULATOR 1
++#define V4L2_OUTPUT_TYPE_ANALOG 2
++#define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY 3
++
++/* capabilities flags */
++#define V4L2_OUT_CAP_PRESETS 0x00000001 /* Supports S_DV_PRESET */
++#define V4L2_OUT_CAP_CUSTOM_TIMINGS 0x00000002 /* Supports S_DV_TIMINGS */
++#define V4L2_OUT_CAP_STD 0x00000004 /* Supports S_STD */
++
++/*
++ * C O N T R O L S
++ */
++struct v4l2_control {
++ __u32 id;
++ __s32 value;
++};
++
++struct v4l2_ext_control {
++ __u32 id;
++ __u32 size;
++ __u32 reserved2[1];
++ union {
++ __s32 value;
++ __s64 value64;
++ char *string;
++ };
++} __attribute__ ((packed));
++
++struct v4l2_ext_controls {
++ __u32 ctrl_class;
++ __u32 count;
++ __u32 error_idx;
++ __u32 reserved[2];
++ struct v4l2_ext_control *controls;
++};
++
++/* Values for ctrl_class field */
++#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
++#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
++#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */
++#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */
++
++#define V4L2_CTRL_ID_MASK (0x0fffffff)
++#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
++#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
++
++enum v4l2_ctrl_type {
++ V4L2_CTRL_TYPE_INTEGER = 1,
++ V4L2_CTRL_TYPE_BOOLEAN = 2,
++ V4L2_CTRL_TYPE_MENU = 3,
++ V4L2_CTRL_TYPE_BUTTON = 4,
++ V4L2_CTRL_TYPE_INTEGER64 = 5,
++ V4L2_CTRL_TYPE_CTRL_CLASS = 6,
++ V4L2_CTRL_TYPE_STRING = 7,
++};
++
++/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
++struct v4l2_queryctrl {
++ __u32 id;
++ enum v4l2_ctrl_type type;
++ __u8 name[32]; /* Whatever */
++ __s32 minimum; /* Note signedness */
++ __s32 maximum;
++ __s32 step;
++ __s32 default_value;
++ __u32 flags;
++ __u32 reserved[2];
++};
++
++/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
++struct v4l2_querymenu {
++ __u32 id;
++ __u32 index;
++ __u8 name[32]; /* Whatever */
++ __u32 reserved;
++};
++
++/* Control flags */
++#define V4L2_CTRL_FLAG_DISABLED 0x0001
++#define V4L2_CTRL_FLAG_GRABBED 0x0002
++#define V4L2_CTRL_FLAG_READ_ONLY 0x0004
++#define V4L2_CTRL_FLAG_UPDATE 0x0008
++#define V4L2_CTRL_FLAG_INACTIVE 0x0010
++#define V4L2_CTRL_FLAG_SLIDER 0x0020
++#define V4L2_CTRL_FLAG_WRITE_ONLY 0x0040
++
++/* Query flag, to be ORed with the control ID */
++#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
++
++/* User-class control IDs defined by V4L2 */
++#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
++#define V4L2_CID_USER_BASE V4L2_CID_BASE
++/* IDs reserved for driver specific controls */
++#define V4L2_CID_PRIVATE_BASE 0x08000000
++
++#define V4L2_CID_USER_CLASS (V4L2_CTRL_CLASS_USER | 1)
++#define V4L2_CID_BRIGHTNESS (V4L2_CID_BASE+0)
++#define V4L2_CID_CONTRAST (V4L2_CID_BASE+1)
++#define V4L2_CID_SATURATION (V4L2_CID_BASE+2)
++#define V4L2_CID_HUE (V4L2_CID_BASE+3)
++#define V4L2_CID_AUDIO_VOLUME (V4L2_CID_BASE+5)
++#define V4L2_CID_AUDIO_BALANCE (V4L2_CID_BASE+6)
++#define V4L2_CID_AUDIO_BASS (V4L2_CID_BASE+7)
++#define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8)
++#define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9)
++#define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10)
++#define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */
++#define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12)
++#define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13)
++#define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14)
++#define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15)
++#define V4L2_CID_GAMMA (V4L2_CID_BASE+16)
++#define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */
++#define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17)
++#define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18)
++#define V4L2_CID_GAIN (V4L2_CID_BASE+19)
++#define V4L2_CID_HFLIP (V4L2_CID_BASE+20)
++#define V4L2_CID_VFLIP (V4L2_CID_BASE+21)
++
++/* Deprecated; use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */
++#define V4L2_CID_HCENTER (V4L2_CID_BASE+22)
++#define V4L2_CID_VCENTER (V4L2_CID_BASE+23)
++
++#define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24)
++enum v4l2_power_line_frequency {
++ V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
++ V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
++ V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
++};
++#define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25)
++#define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26)
++#define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27)
++#define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28)
++#define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29)
++#define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30)
++#define V4L2_CID_COLORFX (V4L2_CID_BASE+31)
++enum v4l2_colorfx {
++ V4L2_COLORFX_NONE = 0,
++ V4L2_COLORFX_BW = 1,
++ V4L2_COLORFX_SEPIA = 2,
++ V4L2_COLORFX_NEGATIVE = 3,
++ V4L2_COLORFX_EMBOSS = 4,
++ V4L2_COLORFX_SKETCH = 5,
++ V4L2_COLORFX_SKY_BLUE = 6,
++ V4L2_COLORFX_GRASS_GREEN = 7,
++ V4L2_COLORFX_SKIN_WHITEN = 8,
++ V4L2_COLORFX_VIVID = 9,
++};
++#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32)
++#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
++
++#define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
++#define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
++
++#define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
++
++#define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+37)
++#define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+38)
++
++/* last CID + 1 */
++#define V4L2_CID_LASTP1 (V4L2_CID_BASE+39)
++
++/* MPEG-class control IDs defined by V4L2 */
++#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
++#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1)
++
++/* MPEG streams */
++#define V4L2_CID_MPEG_STREAM_TYPE (V4L2_CID_MPEG_BASE+0)
++enum v4l2_mpeg_stream_type {
++ V4L2_MPEG_STREAM_TYPE_MPEG2_PS = 0, /* MPEG-2 program stream */
++ V4L2_MPEG_STREAM_TYPE_MPEG2_TS = 1, /* MPEG-2 transport stream */
++ V4L2_MPEG_STREAM_TYPE_MPEG1_SS = 2, /* MPEG-1 system stream */
++ V4L2_MPEG_STREAM_TYPE_MPEG2_DVD = 3, /* MPEG-2 DVD-compatible stream */
++ V4L2_MPEG_STREAM_TYPE_MPEG1_VCD = 4, /* MPEG-1 VCD-compatible stream */
++ V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD = 5, /* MPEG-2 SVCD-compatible stream */
++};
++#define V4L2_CID_MPEG_STREAM_PID_PMT (V4L2_CID_MPEG_BASE+1)
++#define V4L2_CID_MPEG_STREAM_PID_AUDIO (V4L2_CID_MPEG_BASE+2)
++#define V4L2_CID_MPEG_STREAM_PID_VIDEO (V4L2_CID_MPEG_BASE+3)
++#define V4L2_CID_MPEG_STREAM_PID_PCR (V4L2_CID_MPEG_BASE+4)
++#define V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (V4L2_CID_MPEG_BASE+5)
++#define V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (V4L2_CID_MPEG_BASE+6)
++#define V4L2_CID_MPEG_STREAM_VBI_FMT (V4L2_CID_MPEG_BASE+7)
++enum v4l2_mpeg_stream_vbi_fmt {
++ V4L2_MPEG_STREAM_VBI_FMT_NONE = 0, /* No VBI in the MPEG stream */
++ V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, /* VBI in private packets, IVTV format */
++};
++
++/* MPEG audio */
++#define V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ (V4L2_CID_MPEG_BASE+100)
++enum v4l2_mpeg_audio_sampling_freq {
++ V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100 = 0,
++ V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000 = 1,
++ V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000 = 2,
++};
++#define V4L2_CID_MPEG_AUDIO_ENCODING (V4L2_CID_MPEG_BASE+101)
++enum v4l2_mpeg_audio_encoding {
++ V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0,
++ V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1,
++ V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2,
++ V4L2_MPEG_AUDIO_ENCODING_AAC = 3,
++ V4L2_MPEG_AUDIO_ENCODING_AC3 = 4,
++};
++#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102)
++enum v4l2_mpeg_audio_l1_bitrate {
++ V4L2_MPEG_AUDIO_L1_BITRATE_32K = 0,
++ V4L2_MPEG_AUDIO_L1_BITRATE_64K = 1,
++ V4L2_MPEG_AUDIO_L1_BITRATE_96K = 2,
++ V4L2_MPEG_AUDIO_L1_BITRATE_128K = 3,
++ V4L2_MPEG_AUDIO_L1_BITRATE_160K = 4,
++ V4L2_MPEG_AUDIO_L1_BITRATE_192K = 5,
++ V4L2_MPEG_AUDIO_L1_BITRATE_224K = 6,
++ V4L2_MPEG_AUDIO_L1_BITRATE_256K = 7,
++ V4L2_MPEG_AUDIO_L1_BITRATE_288K = 8,
++ V4L2_MPEG_AUDIO_L1_BITRATE_320K = 9,
++ V4L2_MPEG_AUDIO_L1_BITRATE_352K = 10,
++ V4L2_MPEG_AUDIO_L1_BITRATE_384K = 11,
++ V4L2_MPEG_AUDIO_L1_BITRATE_416K = 12,
++ V4L2_MPEG_AUDIO_L1_BITRATE_448K = 13,
++};
++#define V4L2_CID_MPEG_AUDIO_L2_BITRATE (V4L2_CID_MPEG_BASE+103)
++enum v4l2_mpeg_audio_l2_bitrate {
++ V4L2_MPEG_AUDIO_L2_BITRATE_32K = 0,
++ V4L2_MPEG_AUDIO_L2_BITRATE_48K = 1,
++ V4L2_MPEG_AUDIO_L2_BITRATE_56K = 2,
++ V4L2_MPEG_AUDIO_L2_BITRATE_64K = 3,
++ V4L2_MPEG_AUDIO_L2_BITRATE_80K = 4,
++ V4L2_MPEG_AUDIO_L2_BITRATE_96K = 5,
++ V4L2_MPEG_AUDIO_L2_BITRATE_112K = 6,
++ V4L2_MPEG_AUDIO_L2_BITRATE_128K = 7,
++ V4L2_MPEG_AUDIO_L2_BITRATE_160K = 8,
++ V4L2_MPEG_AUDIO_L2_BITRATE_192K = 9,
++ V4L2_MPEG_AUDIO_L2_BITRATE_224K = 10,
++ V4L2_MPEG_AUDIO_L2_BITRATE_256K = 11,
++ V4L2_MPEG_AUDIO_L2_BITRATE_320K = 12,
++ V4L2_MPEG_AUDIO_L2_BITRATE_384K = 13,
++};
++#define V4L2_CID_MPEG_AUDIO_L3_BITRATE (V4L2_CID_MPEG_BASE+104)
++enum v4l2_mpeg_audio_l3_bitrate {
++ V4L2_MPEG_AUDIO_L3_BITRATE_32K = 0,
++ V4L2_MPEG_AUDIO_L3_BITRATE_40K = 1,
++ V4L2_MPEG_AUDIO_L3_BITRATE_48K = 2,
++ V4L2_MPEG_AUDIO_L3_BITRATE_56K = 3,
++ V4L2_MPEG_AUDIO_L3_BITRATE_64K = 4,
++ V4L2_MPEG_AUDIO_L3_BITRATE_80K = 5,
++ V4L2_MPEG_AUDIO_L3_BITRATE_96K = 6,
++ V4L2_MPEG_AUDIO_L3_BITRATE_112K = 7,
++ V4L2_MPEG_AUDIO_L3_BITRATE_128K = 8,
++ V4L2_MPEG_AUDIO_L3_BITRATE_160K = 9,
++ V4L2_MPEG_AUDIO_L3_BITRATE_192K = 10,
++ V4L2_MPEG_AUDIO_L3_BITRATE_224K = 11,
++ V4L2_MPEG_AUDIO_L3_BITRATE_256K = 12,
++ V4L2_MPEG_AUDIO_L3_BITRATE_320K = 13,
++};
++#define V4L2_CID_MPEG_AUDIO_MODE (V4L2_CID_MPEG_BASE+105)
++enum v4l2_mpeg_audio_mode {
++ V4L2_MPEG_AUDIO_MODE_STEREO = 0,
++ V4L2_MPEG_AUDIO_MODE_JOINT_STEREO = 1,
++ V4L2_MPEG_AUDIO_MODE_DUAL = 2,
++ V4L2_MPEG_AUDIO_MODE_MONO = 3,
++};
++#define V4L2_CID_MPEG_AUDIO_MODE_EXTENSION (V4L2_CID_MPEG_BASE+106)
++enum v4l2_mpeg_audio_mode_extension {
++ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4 = 0,
++ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8 = 1,
++ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12 = 2,
++ V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16 = 3,
++};
++#define V4L2_CID_MPEG_AUDIO_EMPHASIS (V4L2_CID_MPEG_BASE+107)
++enum v4l2_mpeg_audio_emphasis {
++ V4L2_MPEG_AUDIO_EMPHASIS_NONE = 0,
++ V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS = 1,
++ V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17 = 2,
++};
++#define V4L2_CID_MPEG_AUDIO_CRC (V4L2_CID_MPEG_BASE+108)
++enum v4l2_mpeg_audio_crc {
++ V4L2_MPEG_AUDIO_CRC_NONE = 0,
++ V4L2_MPEG_AUDIO_CRC_CRC16 = 1,
++};
++#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109)
++#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110)
++#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111)
++enum v4l2_mpeg_audio_ac3_bitrate {
++ V4L2_MPEG_AUDIO_AC3_BITRATE_32K = 0,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_40K = 1,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_48K = 2,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_56K = 3,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_64K = 4,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_80K = 5,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_96K = 6,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_112K = 7,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_128K = 8,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_160K = 9,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_192K = 10,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_224K = 11,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_256K = 12,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_320K = 13,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_384K = 14,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_448K = 15,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_512K = 16,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17,
++ V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18,
++};
++
++/* MPEG video */
++#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200)
++enum v4l2_mpeg_video_encoding {
++ V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0,
++ V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1,
++ V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2,
++};
++#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201)
++enum v4l2_mpeg_video_aspect {
++ V4L2_MPEG_VIDEO_ASPECT_1x1 = 0,
++ V4L2_MPEG_VIDEO_ASPECT_4x3 = 1,
++ V4L2_MPEG_VIDEO_ASPECT_16x9 = 2,
++ V4L2_MPEG_VIDEO_ASPECT_221x100 = 3,
++};
++#define V4L2_CID_MPEG_VIDEO_B_FRAMES (V4L2_CID_MPEG_BASE+202)
++#define V4L2_CID_MPEG_VIDEO_GOP_SIZE (V4L2_CID_MPEG_BASE+203)
++#define V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (V4L2_CID_MPEG_BASE+204)
++#define V4L2_CID_MPEG_VIDEO_PULLDOWN (V4L2_CID_MPEG_BASE+205)
++#define V4L2_CID_MPEG_VIDEO_BITRATE_MODE (V4L2_CID_MPEG_BASE+206)
++enum v4l2_mpeg_video_bitrate_mode {
++ V4L2_MPEG_VIDEO_BITRATE_MODE_VBR = 0,
++ V4L2_MPEG_VIDEO_BITRATE_MODE_CBR = 1,
++};
++#define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207)
++#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208)
++#define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209)
++#define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210)
++#define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211)
++
++/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
++#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
++#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)
++enum v4l2_mpeg_cx2341x_video_spatial_filter_mode {
++ V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL = 0,
++ V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO = 1,
++};
++#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+1)
++#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+2)
++enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type {
++ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF = 0,
++ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
++ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT = 2,
++ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE = 3,
++ V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE = 4,
++};
++#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+3)
++enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type {
++ V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF = 0,
++ V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR = 1,
++};
++#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+4)
++enum v4l2_mpeg_cx2341x_video_temporal_filter_mode {
++ V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL = 0,
++ V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO = 1,
++};
++#define V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (V4L2_CID_MPEG_CX2341X_BASE+5)
++#define V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE (V4L2_CID_MPEG_CX2341X_BASE+6)
++enum v4l2_mpeg_cx2341x_video_median_filter_type {
++ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF = 0,
++ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR = 1,
++ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT = 2,
++ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT = 3,
++ V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG = 4,
++};
++#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+7)
++#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8)
++#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9)
++#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10)
++#define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11)
++
++/* Camera class control IDs */
++#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
++#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
++
++#define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1)
++enum v4l2_exposure_auto_type {
++ V4L2_EXPOSURE_AUTO = 0,
++ V4L2_EXPOSURE_MANUAL = 1,
++ V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
++ V4L2_EXPOSURE_APERTURE_PRIORITY = 3
++};
++#define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2)
++#define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3)
++
++#define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4)
++#define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5)
++#define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6)
++#define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7)
++
++#define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8)
++#define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9)
++
++#define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10)
++#define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11)
++#define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12)
++
++#define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13)
++#define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14)
++#define V4L2_CID_ZOOM_CONTINUOUS (V4L2_CID_CAMERA_CLASS_BASE+15)
++
++#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
++
++#define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17)
++#define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18)
++
++/* FM Modulator class control IDs */
++#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
++#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
++
++#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1)
++#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
++#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3)
++#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5)
++#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
++
++#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
++#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65)
++#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 66)
++
++#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 80)
++#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FM_TX_CLASS_BASE + 81)
++#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82)
++#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FM_TX_CLASS_BASE + 83)
++#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 84)
++
++#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 96)
++#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97)
++#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FM_TX_CLASS_BASE + 98)
++
++#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112)
++enum v4l2_preemphasis {
++ V4L2_PREEMPHASIS_DISABLED = 0,
++ V4L2_PREEMPHASIS_50_uS = 1,
++ V4L2_PREEMPHASIS_75_uS = 2,
++};
++#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113)
++#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114)
++
++/*
++ * T U N I N G
++ */
++struct v4l2_tuner {
++ __u32 index;
++ __u8 name[32];
++ enum v4l2_tuner_type type;
++ __u32 capability;
++ __u32 rangelow;
++ __u32 rangehigh;
++ __u32 rxsubchans;
++ __u32 audmode;
++ __s32 signal;
++ __s32 afc;
++ __u32 reserved[4];
++};
++
++struct v4l2_modulator {
++ __u32 index;
++ __u8 name[32];
++ __u32 capability;
++ __u32 rangelow;
++ __u32 rangehigh;
++ __u32 txsubchans;
++ __u32 reserved[4];
++};
++
++/* Flags for the 'capability' field */
++#define V4L2_TUNER_CAP_LOW 0x0001
++#define V4L2_TUNER_CAP_NORM 0x0002
++#define V4L2_TUNER_CAP_STEREO 0x0010
++#define V4L2_TUNER_CAP_LANG2 0x0020
++#define V4L2_TUNER_CAP_SAP 0x0020
++#define V4L2_TUNER_CAP_LANG1 0x0040
++#define V4L2_TUNER_CAP_RDS 0x0080
++#define V4L2_TUNER_CAP_RDS_BLOCK_IO 0x0100
++#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
++
++/* Flags for the 'rxsubchans' field */
++#define V4L2_TUNER_SUB_MONO 0x0001
++#define V4L2_TUNER_SUB_STEREO 0x0002
++#define V4L2_TUNER_SUB_LANG2 0x0004
++#define V4L2_TUNER_SUB_SAP 0x0004
++#define V4L2_TUNER_SUB_LANG1 0x0008
++#define V4L2_TUNER_SUB_RDS 0x0010
++
++/* Values for the 'audmode' field */
++#define V4L2_TUNER_MODE_MONO 0x0000
++#define V4L2_TUNER_MODE_STEREO 0x0001
++#define V4L2_TUNER_MODE_LANG2 0x0002
++#define V4L2_TUNER_MODE_SAP 0x0002
++#define V4L2_TUNER_MODE_LANG1 0x0003
++#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
++
++struct v4l2_frequency {
++ __u32 tuner;
++ enum v4l2_tuner_type type;
++ __u32 frequency;
++ __u32 reserved[8];
++};
++
++struct v4l2_hw_freq_seek {
++ __u32 tuner;
++ enum v4l2_tuner_type type;
++ __u32 seek_upward;
++ __u32 wrap_around;
++ __u32 spacing;
++ __u32 reserved[7];
++};
++
++/*
++ * R D S
++ */
++
++struct v4l2_rds_data {
++ __u8 lsb;
++ __u8 msb;
++ __u8 block;
++} __attribute__ ((packed));
++
++#define V4L2_RDS_BLOCK_MSK 0x7
++#define V4L2_RDS_BLOCK_A 0
++#define V4L2_RDS_BLOCK_B 1
++#define V4L2_RDS_BLOCK_C 2
++#define V4L2_RDS_BLOCK_D 3
++#define V4L2_RDS_BLOCK_C_ALT 4
++#define V4L2_RDS_BLOCK_INVALID 7
++
++#define V4L2_RDS_BLOCK_CORRECTED 0x40
++#define V4L2_RDS_BLOCK_ERROR 0x80
++
++/*
++ * A U D I O
++ */
++struct v4l2_audio {
++ __u32 index;
++ __u8 name[32];
++ __u32 capability;
++ __u32 mode;
++ __u32 reserved[2];
++};
++
++/* Flags for the 'capability' field */
++#define V4L2_AUDCAP_STEREO 0x00001
++#define V4L2_AUDCAP_AVL 0x00002
++
++/* Flags for the 'mode' field */
++#define V4L2_AUDMODE_AVL 0x00001
++
++struct v4l2_audioout {
++ __u32 index;
++ __u8 name[32];
++ __u32 capability;
++ __u32 mode;
++ __u32 reserved[2];
++};
++
++/*
++ * M P E G S E R V I C E S
++ *
++ * NOTE: EXPERIMENTAL API
++ */
++#if 1
++#define V4L2_ENC_IDX_FRAME_I (0)
++#define V4L2_ENC_IDX_FRAME_P (1)
++#define V4L2_ENC_IDX_FRAME_B (2)
++#define V4L2_ENC_IDX_FRAME_MASK (0xf)
++
++struct v4l2_enc_idx_entry {
++ __u64 offset;
++ __u64 pts;
++ __u32 length;
++ __u32 flags;
++ __u32 reserved[2];
++};
++
++#define V4L2_ENC_IDX_ENTRIES (64)
++struct v4l2_enc_idx {
++ __u32 entries;
++ __u32 entries_cap;
++ __u32 reserved[4];
++ struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES];
++};
++
++
++#define V4L2_ENC_CMD_START (0)
++#define V4L2_ENC_CMD_STOP (1)
++#define V4L2_ENC_CMD_PAUSE (2)
++#define V4L2_ENC_CMD_RESUME (3)
++
++/* Flags for V4L2_ENC_CMD_STOP */
++#define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0)
++
++struct v4l2_encoder_cmd {
++ __u32 cmd;
++ __u32 flags;
++ union {
++ struct {
++ __u32 data[8];
++ } raw;
++ };
++};
++
++#endif
++
++
++/*
++ * D A T A S E R V I C E S ( V B I )
++ *
++ * Data services API by Michael Schimek
++ */
++
++/* Raw VBI */
++struct v4l2_vbi_format {
++ __u32 sampling_rate; /* in 1 Hz */
++ __u32 offset;
++ __u32 samples_per_line;
++ __u32 sample_format; /* V4L2_PIX_FMT_* */
++ __s32 start[2];
++ __u32 count[2];
++ __u32 flags; /* V4L2_VBI_* */
++ __u32 reserved[2]; /* must be zero */
++};
++
++/* VBI flags */
++#define V4L2_VBI_UNSYNC (1 << 0)
++#define V4L2_VBI_INTERLACED (1 << 1)
++
++/* Sliced VBI
++ *
++ * This implements is a proposal V4L2 API to allow SLICED VBI
++ * required for some hardware encoders. It should change without
++ * notice in the definitive implementation.
++ */
++
++struct v4l2_sliced_vbi_format {
++ __u16 service_set;
++ /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
++ service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
++ (equals frame lines 313-336 for 625 line video
++ standards, 263-286 for 525 line standards) */
++ __u16 service_lines[2][24];
++ __u32 io_size;
++ __u32 reserved[2]; /* must be zero */
++};
++
++/* Teletext World System Teletext
++ (WST), defined on ITU-R BT.653-2 */
++#define V4L2_SLICED_TELETEXT_B (0x0001)
++/* Video Program System, defined on ETS 300 231*/
++#define V4L2_SLICED_VPS (0x0400)
++/* Closed Caption, defined on EIA-608 */
++#define V4L2_SLICED_CAPTION_525 (0x1000)
++/* Wide Screen System, defined on ITU-R BT1119.1 */
++#define V4L2_SLICED_WSS_625 (0x4000)
++
++#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
++#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
++
++struct v4l2_sliced_vbi_cap {
++ __u16 service_set;
++ /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
++ service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
++ (equals frame lines 313-336 for 625 line video
++ standards, 263-286 for 525 line standards) */
++ __u16 service_lines[2][24];
++ enum v4l2_buf_type type;
++ __u32 reserved[3]; /* must be 0 */
++};
++
++struct v4l2_sliced_vbi_data {
++ __u32 id;
++ __u32 field; /* 0: first field, 1: second field */
++ __u32 line; /* 1-23 */
++ __u32 reserved; /* must be 0 */
++ __u8 data[48];
++};
++
++/*
++ * Sliced VBI data inserted into MPEG Streams
++ */
++
++/*
++ * V4L2_MPEG_STREAM_VBI_FMT_IVTV:
++ *
++ * Structure of payload contained in an MPEG 2 Private Stream 1 PES Packet in an
++ * MPEG-2 Program Pack that contains V4L2_MPEG_STREAM_VBI_FMT_IVTV Sliced VBI
++ * data
++ *
++ * Note, the MPEG-2 Program Pack and Private Stream 1 PES packet header
++ * definitions are not included here. See the MPEG-2 specifications for details
++ * on these headers.
++ */
++
++/* Line type IDs */
++#define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1)
++#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4)
++#define V4L2_MPEG_VBI_IVTV_WSS_625 (5)
++#define V4L2_MPEG_VBI_IVTV_VPS (7)
++
++struct v4l2_mpeg_vbi_itv0_line {
++ __u8 id; /* One of V4L2_MPEG_VBI_IVTV_* above */
++ __u8 data[42]; /* Sliced VBI data for the line */
++} __attribute__ ((packed));
++
++struct v4l2_mpeg_vbi_itv0 {
++ __le32 linemask[2]; /* Bitmasks of VBI service lines present */
++ struct v4l2_mpeg_vbi_itv0_line line[35];
++} __attribute__ ((packed));
++
++struct v4l2_mpeg_vbi_ITV0 {
++ struct v4l2_mpeg_vbi_itv0_line line[36];
++} __attribute__ ((packed));
++
++#define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0"
++#define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0"
++
++struct v4l2_mpeg_vbi_fmt_ivtv {
++ __u8 magic[4];
++ union {
++ struct v4l2_mpeg_vbi_itv0 itv0;
++ struct v4l2_mpeg_vbi_ITV0 ITV0;
++ };
++} __attribute__ ((packed));
++
++/*
++ * A G G R E G A T E S T R U C T U R E S
++ */
++
++/**
++ * struct v4l2_plane_pix_format - additional, per-plane format definition
++ * @sizeimage: maximum size in bytes required for data, for which
++ * this plane will be used
++ * @bytesperline: distance in bytes between the leftmost pixels in two
++ * adjacent lines
++ */
++struct v4l2_plane_pix_format {
++ __u32 sizeimage;
++ __u16 bytesperline;
++ __u16 reserved[7];
++} __attribute__ ((packed));
++
++/**
++ * struct v4l2_pix_format_mplane - multiplanar format definition
++ * @width: image width in pixels
++ * @height: image height in pixels
++ * @pixelformat: little endian four character code (fourcc)
++ * @field: field order (for interlaced video)
++ * @colorspace: supplemental to pixelformat
++ * @plane_fmt: per-plane information
++ * @num_planes: number of planes for this format
++ */
++struct v4l2_pix_format_mplane {
++ __u32 width;
++ __u32 height;
++ __u32 pixelformat;
++ enum v4l2_field field;
++ enum v4l2_colorspace colorspace;
++
++ struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
++ __u8 num_planes;
++ __u8 reserved[11];
++} __attribute__ ((packed));
++
++/**
++ * struct v4l2_format - stream data format
++ * @type: type of the data stream
++ * @pix: definition of an image format
++ * @pix_mp: definition of a multiplanar image format
++ * @win: definition of an overlaid image
++ * @vbi: raw VBI capture or output parameters
++ * @sliced: sliced VBI capture or output parameters
++ * @raw_data: placeholder for future extensions and custom formats
++ */
++struct v4l2_format {
++ enum v4l2_buf_type type;
++ union {
++ struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
++ struct v4l2_pix_format_mplane pix_mp; /* V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE */
++ struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
++ struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
++ struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
++ __u8 raw_data[200]; /* user-defined */
++ } fmt;
++};
++
++/* Stream type-dependent parameters
++ */
++struct v4l2_streamparm {
++ enum v4l2_buf_type type;
++ union {
++ struct v4l2_captureparm capture;
++ struct v4l2_outputparm output;
++ __u8 raw_data[200]; /* user-defined */
++ } parm;
++};
++
++/*
++ * E V E N T S
++ */
++
++#define V4L2_EVENT_ALL 0
++#define V4L2_EVENT_VSYNC 1
++#define V4L2_EVENT_EOS 2
++#define V4L2_EVENT_PRIVATE_START 0x08000000
++
++/* Payload for V4L2_EVENT_VSYNC */
++struct v4l2_event_vsync {
++ /* Can be V4L2_FIELD_ANY, _NONE, _TOP or _BOTTOM */
++ __u8 field;
++} __attribute__ ((packed));
++
++struct v4l2_event {
++ __u32 type;
++ union {
++ struct v4l2_event_vsync vsync;
++ __u8 data[64];
++ } u;
++ __u32 pending;
++ __u32 sequence;
++ struct timespec timestamp;
++ __u32 reserved[9];
++};
++
++struct v4l2_event_subscription {
++ __u32 type;
++ __u32 reserved[7];
++};
++
++/*
++ * A D V A N C E D D E B U G G I N G
++ *
++ * NOTE: EXPERIMENTAL API, NEVER RELY ON THIS IN APPLICATIONS!
++ * FOR DEBUGGING, TESTING AND INTERNAL USE ONLY!
++ */
++
++/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */
++
++#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */
++#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */
++#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */
++#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */
++
++struct v4l2_dbg_match {
++ __u32 type; /* Match type */
++ union { /* Match this chip, meaning determined by type */
++ __u32 addr;
++ char name[32];
++ };
++} __attribute__ ((packed));
++
++struct v4l2_dbg_register {
++ struct v4l2_dbg_match match;
++ __u32 size; /* register size in bytes */
++ __u64 reg;
++ __u64 val;
++} __attribute__ ((packed));
++
++/* VIDIOC_DBG_G_CHIP_IDENT */
++struct v4l2_dbg_chip_ident {
++ struct v4l2_dbg_match match;
++ __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */
++ __u32 revision; /* chip revision, chip specific */
++} __attribute__ ((packed));
++
++/*
++ * I O C T L C O D E S F O R V I D E O D E V I C E S
++ *
++ */
++#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
++#define VIDIOC_RESERVED _IO('V', 1)
++#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
++#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
++#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
++#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
++#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
++#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
++#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
++#define VIDIOC_OVERLAY _IOW('V', 14, int)
++#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
++#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
++#define VIDIOC_STREAMON _IOW('V', 18, int)
++#define VIDIOC_STREAMOFF _IOW('V', 19, int)
++#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
++#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
++#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
++#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
++#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
++#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
++#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
++#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
++#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
++#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
++#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
++#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
++#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
++#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
++#define VIDIOC_G_INPUT _IOR('V', 38, int)
++#define VIDIOC_S_INPUT _IOWR('V', 39, int)
++#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
++#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
++#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
++#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
++#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
++#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
++#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
++#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
++#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
++#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
++#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
++#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
++#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
++#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
++#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
++#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
++#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
++#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
++#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority)
++#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority)
++#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
++#define VIDIOC_LOG_STATUS _IO('V', 70)
++#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
++#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
++#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
++#if 1
++#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
++#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
++#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
++#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
++#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
++#endif
++
++#if 1
++/* Experimental, meant for debugging, testing and internal use.
++ Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined.
++ You must be root to use these ioctls. Never use these in applications! */
++#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
++#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register)
++
++/* Experimental, meant for debugging, testing and internal use.
++ Never use this ioctl in applications! */
++#define VIDIOC_DBG_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_dbg_chip_ident)
++#endif
++
++#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
++#define VIDIOC_ENUM_DV_PRESETS _IOWR('V', 83, struct v4l2_dv_enum_preset)
++#define VIDIOC_S_DV_PRESET _IOWR('V', 84, struct v4l2_dv_preset)
++#define VIDIOC_G_DV_PRESET _IOWR('V', 85, struct v4l2_dv_preset)
++#define VIDIOC_QUERY_DV_PRESET _IOR('V', 86, struct v4l2_dv_preset)
++#define VIDIOC_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings)
++#define VIDIOC_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings)
++#define VIDIOC_DQEVENT _IOR('V', 89, struct v4l2_event)
++#define VIDIOC_SUBSCRIBE_EVENT _IOW('V', 90, struct v4l2_event_subscription)
++#define VIDIOC_UNSUBSCRIBE_EVENT _IOW('V', 91, struct v4l2_event_subscription)
++
++#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
++
++#endif /* __LINUX_VIDEODEV2_H */
diff --git a/staging/xf86-video-vesa/PKGBUILD b/staging/xf86-video-vesa/PKGBUILD
new file mode 100644
index 000000000..08933fb5a
--- /dev/null
+++ b/staging/xf86-video-vesa/PKGBUILD
@@ -0,0 +1,40 @@
+# $Id: PKGBUILD 149908 2012-02-11 15:13:43Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-vesa
+pkgver=2.3.0
+pkgrel=8
+_gitver=4ba7306fd0c9533750d389829e2cbf0522e149b3
+pkgdesc="X.org vesa video driver"
+arch=(i686 x86_64)
+license=('custom')
+url="http://xorg.freedesktop.org/"
+depends=('glibc')
+makedepends=('pkgconfig' 'xorg-server-devel>=1.11.99.903')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(#${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ http://cgit.freedesktop.org/xorg/driver/xf86-video-vesa/snapshot/xf86-video-vesa-${_gitver}.tar.gz
+ #git-fixes.patch
+ revert-kernelcheck.patch)
+sha1sums=('52f5bf577038c6fe7819743ceac787bb619b6d47'
+ 'c14454521ac91aaa08aad8a6025d7720a613d54b')
+
+build() {
+ #cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${srcdir}/${pkgname}*
+ #patch -Np1 -i "${srcdir}/git-fixes.patch"
+ patch -Np1 -R -i "${srcdir}/revert-kernelcheck.patch"
+ autoreconf -fi
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ #cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${srcdir}/${pkgname}*
+ make DESTDIR="${pkgdir}" install
+ install -d -m755 "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-vesa/git-fixes.patch b/staging/xf86-video-vesa/git-fixes.patch
new file mode 100644
index 000000000..c4f442265
--- /dev/null
+++ b/staging/xf86-video-vesa/git-fixes.patch
@@ -0,0 +1,444 @@
+diff --git a/COPYING b/COPYING
+index 22b4b13..f101fb8 100644
+--- a/COPYING
++++ b/COPYING
+@@ -1,4 +1,5 @@
+ Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
++Copyright 2008 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+diff --git a/configure.ac b/configure.ac
+index ff4713d..2e4f542 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -20,45 +20,44 @@
+ #
+ # Process this file with autoconf to produce a configure script
+
+-AC_PREREQ(2.57)
++# Initialize Autoconf
++AC_PREREQ([2.60])
+ AC_INIT([xf86-video-vesa],
+- 2.3.0,
++ [2.3.0],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
+- xf86-video-vesa)
+-
++ [xf86-video-vesa])
+ AC_CONFIG_SRCDIR([Makefile.am])
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
+ AC_CONFIG_AUX_DIR(.)
+
++# Initialize Automake
+ AM_INIT_AUTOMAKE([foreign dist-bzip2])
+-
+ AM_MAINTAINER_MODE
+
+-# Require xorg-macros: XORG_DEFAULT_OPTIONS
++# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+ m4_ifndef([XORG_MACROS_VERSION],
+- [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+-XORG_MACROS_VERSION(1.3)
++ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
++XORG_MACROS_VERSION(1.8)
+ XORG_DEFAULT_OPTIONS
+
+-# Checks for programs.
++# Initialize libtool
+ AC_DISABLE_STATIC
+ AC_PROG_LIBTOOL
+-AC_PROG_CC
+
+ AH_TOP([#include "xorg-server.h"])
+
++# Define a configure option for an alternate module directory
+ AC_ARG_WITH(xorg-module-dir, [ --with-xorg-module-dir=DIR ],
+ [ moduledir="$withval" ],
+ [ moduledir="$libdir/xorg/modules" ])
+ AC_SUBST(moduledir)
+
+-
+-# Checks for extensions
++# Store the list of server defined optional extensions in REQUIRED_MODULES
+ XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+ XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+-# Checks for pkg-config packages
++# Obtain compiler/linker options for the driver dependencies
+ PKG_CHECK_MODULES(XORG, xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES)
+ PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
+ HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
+@@ -93,21 +92,14 @@ if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+ fi
+ AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
+-CFLAGS="$CFLAGS $XORG_CFLAGS "' -I$(top_srcdir)/src'
+-INCLUDES="$XORG_INCS "'-I$(top_srcdir)/src'
+-AC_SUBST([CFLAGS])
+-AC_SUBST([INCLUDES])
+-
+ # Checks for libraries.
+
+-# Checks for header files.
+-AC_HEADER_STDC
+-
+ DRIVER_NAME=vesa
+ AC_SUBST([DRIVER_NAME])
+
+-AC_OUTPUT([
+- Makefile
+- src/Makefile
+- man/Makefile
++AC_CONFIG_FILES([
++ Makefile
++ src/Makefile
++ man/Makefile
+ ])
++AC_OUTPUT
+diff --git a/man/Makefile.am b/man/Makefile.am
+index f0eb29b..b3688ce 100644
+--- a/man/Makefile.am
++++ b/man/Makefile.am
+@@ -1,27 +1,24 @@
+ #
+ # 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.
++#
++# Permission is hereby granted, free of charge, to any person obtaining a
++# copy of this software and associated documentation files (the "Software"),
++# to deal in the Software without restriction, including without limitation
++# the rights to use, copy, modify, merge, publish, distribute, sublicense,
++# and/or sell copies of the Software, and to permit persons to whom the
++# Software is furnished to do so, subject to the following conditions:
++#
++# The above copyright notice and this permission notice (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 NONINFRINGEMENT. IN NO EVENT SHALL
++# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++# DEALINGS IN THE SOFTWARE.
+ #
+
+ drivermandir = $(DRIVER_MAN_DIR)
+@@ -34,25 +31,11 @@ EXTRA_DIST = @DRIVER_NAME@.man
+
+ CLEANFILES = $(driverman_DATA)
+
+-SED = sed
+
+-# Strings to replace in man pages
+-XORGRELSTRING = @PACKAGE_STRING@
+- XORGMANNAME = X Version 11
++# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+
+-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) < $< > $@
++ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
+diff --git a/man/vesa.man b/man/vesa.man
+index 19cb766..ce4b369 100644
+--- a/man/vesa.man
++++ b/man/vesa.man
+@@ -1,4 +1,3 @@
+-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.man,v 1.2 2001/01/27 18:20:56 dawes Exp $
+ .\" shorthand for double quote that works everywhere.
+ .ds q \N'34'
+ .TH VESA __drivermansuffix__ __vendorversion__
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 88da8a2..dc702f0 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -24,6 +24,9 @@
+ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end
+ # _ladir passes a dummy rpath to libtool so the thing will actually link
+ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
++
++AM_CFLAGS = $(XORG_CFLAGS) $(PCIACCESS_CFLAGS)
++
+ vesa_drv_la_LTLIBRARIES = vesa_drv.la
+ vesa_drv_la_LDFLAGS = -module -avoid-version
+ vesa_drv_ladir = @moduledir@/drivers
+diff --git a/src/vesa.c b/src/vesa.c
+index 034a019..61d3550 100644
+--- a/src/vesa.c
++++ b/src/vesa.c
+@@ -281,7 +281,7 @@ static VESAPtr
+ VESAGetRec(ScrnInfoPtr pScrn)
+ {
+ if (!pScrn->driverPrivate)
+- pScrn->driverPrivate = xcalloc(sizeof(VESARec), 1);
++ pScrn->driverPrivate = calloc(sizeof(VESARec), 1);
+
+ return ((VESAPtr)pScrn->driverPrivate);
+ }
+@@ -296,7 +296,7 @@ VESASetModeParameters(vbeInfoPtr pVbe, DisplayModePtr vbemode,
+
+ data = (VbeModeInfoData *)vbemode->Private;
+
+- data->block = xcalloc(sizeof(VbeCRTCInfoBlock), 1);
++ data->block = calloc(sizeof(VbeCRTCInfoBlock), 1);
+ data->block->HorizontalTotal = ddcmode->HTotal;
+ data->block->HorizontalSyncStart = ddcmode->HSyncStart;
+ data->block->HorizontalSyncEnd = ddcmode->HSyncEnd;
+@@ -317,6 +317,30 @@ VESASetModeParameters(vbeInfoPtr pVbe, DisplayModePtr vbemode,
+ (double)(ddcmode->HTotal * ddcmode->VTotal));
+ }
+
++/*
++ * Despite that VBE gives you pixel granularity for mode sizes, some BIOSes
++ * think they can only give sizes in multiples of character cells; and
++ * indeed, the reference CVT and GTF formulae only give results where
++ * (h % 8) == 0. Whatever, let's just try to cope. What we're looking for
++ * here is cases where the display says 1366x768 and the BIOS says 1360x768.
++ */
++static Bool
++vesaModesCloseEnough(DisplayModePtr edid, DisplayModePtr vbe)
++{
++ if (!(edid->type & M_T_DRIVER))
++ return FALSE;
++
++ /* never seen a height granularity... */
++ if (edid->VDisplay != vbe->VDisplay)
++ return FALSE;
++
++ if (edid->HDisplay >= vbe->HDisplay &&
++ (edid->HDisplay & ~7) == (vbe->HDisplay & ~7))
++ return TRUE;
++
++ return FALSE;
++}
++
+ static ModeStatus
+ VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
+ {
+@@ -358,9 +382,7 @@ VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
+ */
+ if (pScrn->monitor->DDC) {
+ for (mode = pScrn->monitor->Modes; mode; mode = mode->next) {
+- if (mode->type & M_T_DRIVER &&
+- mode->HDisplay == p->HDisplay &&
+- mode->VDisplay == p->VDisplay) {
++ if (vesaModesCloseEnough(mode, p)) {
+ if (xf86CheckModeForMonitor(mode, mon) == MODE_OK) {
+ found = 1;
+ break;
+@@ -391,7 +413,8 @@ VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
+ for (v = mon->vrefresh[0].lo; v <= mon->vrefresh[0].hi; v++) {
+ mode = xf86GTFMode(p->HDisplay, p->VDisplay, v, 0, 0);
+ ret = xf86CheckModeForMonitor(mode, mon);
+- xfree(mode);
++ free(mode->name);
++ free(mode);
+ if (ret == MODE_OK)
+ break;
+ }
+@@ -431,8 +454,14 @@ VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
+ pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+ if (pScrn != NULL) {
+- VESAPtr pVesa = VESAGetRec(pScrn);
++ VESAPtr pVesa;
++
++ if (pci_device_has_kernel_driver(dev)) {
++ ErrorF("vesa: Ignoring device with a bound kernel driver\n");
++ return FALSE;
++ }
+
++ pVesa = VESAGetRec(pScrn);
+ VESAInitScrn(pScrn);
+ pVesa->pciInfo = dev;
+ }
+@@ -480,7 +509,7 @@ VESAProbe(DriverPtr drv, int flags)
+ }
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+ }
+ }
+ #endif
+@@ -503,11 +532,11 @@ VESAProbe(DriverPtr drv, int flags)
+ foundScreen = TRUE;
+ }
+ }
+- xfree(usedChips);
++ free(usedChips);
+ }
+ #endif
+
+- xfree(devSections);
++ free(devSections);
+
+ return (foundScreen);
+ }
+@@ -554,9 +583,9 @@ VESAFreeRec(ScrnInfoPtr pScrn)
+ VbeModeInfoData *data = (VbeModeInfoData*)mode->Private;
+
+ if (data->block)
+- xfree(data->block);
++ free(data->block);
+
+- xfree(data);
++ free(data);
+
+ mode->Private = NULL;
+ }
+@@ -564,12 +593,12 @@ VESAFreeRec(ScrnInfoPtr pScrn)
+ } while (mode && mode != pScrn->modes);
+ }
+ #endif
+- xfree(pVesa->monitor);
+- xfree(pVesa->vbeInfo);
+- xfree(pVesa->pal);
+- xfree(pVesa->savedPal);
+- xfree(pVesa->fonts);
+- xfree(pScrn->driverPrivate);
++ free(pVesa->monitor);
++ free(pVesa->vbeInfo);
++ free(pVesa->pal);
++ free(pVesa->savedPal);
++ free(pVesa->fonts);
++ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ }
+
+@@ -712,7 +741,7 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
+ else {
+ void *panelid = VBEReadPanelID(pVesa->pVbe);
+ VBEInterpretPanelID(pScrn->scrnIndex, panelid);
+- xfree(panelid);
++ free(panelid);
+ }
+ #endif
+
+@@ -805,7 +834,7 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
+
+ /* options */
+ xf86CollectOptions(pScrn, NULL);
+- if (!(pVesa->Options = xalloc(sizeof(VESAOptions)))) {
++ if (!(pVesa->Options = malloc(sizeof(VESAOptions)))) {
+ vbeFree(pVesa->pVbe);
+ return FALSE;
+ }
+@@ -940,7 +969,7 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+ pScrn->bitsPerPixel = 8;
+
+ if (pVesa->shadowFB) {
+- pVesa->shadow = xcalloc(1, pScrn->displayWidth * pScrn->virtualY *
++ pVesa->shadow = calloc(1, pScrn->displayWidth * pScrn->virtualY *
+ ((pScrn->bitsPerPixel + 7) / 8));
+ if (!pVesa->shadow) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+@@ -1119,10 +1148,10 @@ VESACloseScreen(int scrnIndex, ScreenPtr pScreen)
+ }
+ if (pVesa->shadowFB && pVesa->shadow) {
+ shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+- xfree(pVesa->shadow);
++ free(pVesa->shadow);
+ }
+ if (pVesa->pDGAMode) {
+- xfree(pVesa->pDGAMode);
++ free(pVesa->pDGAMode);
+ pVesa->pDGAMode = NULL;
+ pVesa->nDGAMode = 0;
+ }
+@@ -1180,7 +1209,7 @@ VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
+ * Free it as it will not be any longer useful
+ */
+ xf86ErrorF(", mode set without customized refresh.\n");
+- xfree(data->block);
++ free(data->block);
+ data->block = NULL;
+ data->mode &= ~(1 << 11);
+ }
+@@ -1315,7 +1344,7 @@ VESALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ int base;
+
+ if (pVesa->pal == NULL)
+- pVesa->pal = xcalloc(1, sizeof(CARD32) * 256);
++ pVesa->pal = calloc(1, sizeof(CARD32) * 256);
+
+ for (i = 0, base = idx = indices[i]; i < numColors; i++, idx++) {
+ int j = indices[i];
+@@ -1414,7 +1443,7 @@ SaveFonts(ScrnInfoPtr pScrn)
+ if (attr10 & 0x01)
+ return;
+
+- pVesa->fonts = xalloc(16384);
++ pVesa->fonts = malloc(16384);
+
+ /* save the registers that are needed here */
+ miscOut = ReadMiscOut();
+@@ -1622,7 +1651,7 @@ VESASaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function)
+ && function == MODE_SAVE) {
+ /* don't rely on the memory not being touched */
+ if (pVesa->pstate == NULL)
+- pVesa->pstate = xalloc(pVesa->stateSize);
++ pVesa->pstate = malloc(pVesa->stateSize);
+ memcpy(pVesa->pstate, pVesa->state, pVesa->stateSize);
+ }
+ }
+@@ -1737,7 +1766,7 @@ VESADGAAddModes(ScrnInfoPtr pScrn)
+ DGAModePtr pDGAMode;
+
+ do {
+- pDGAMode = xrealloc(pVesa->pDGAMode,
++ pDGAMode = realloc(pVesa->pDGAMode,
+ (pVesa->nDGAMode + 1) * sizeof(DGAModeRec));
+ if (!pDGAMode)
+ break;
+diff --git a/src/vesa.h b/src/vesa.h
+index 4656e4c..89245b9 100644
+--- a/src/vesa.h
++++ b/src/vesa.h
+@@ -25,8 +25,6 @@
+ * Conectiva Linux.
+ *
+ * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
+- *
+- * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.h,v 1.12 2002/08/06 13:46:27 dawes Exp $
+ */
+
+ #ifndef _VESA_H_
diff --git a/staging/xf86-video-vesa/revert-kernelcheck.patch b/staging/xf86-video-vesa/revert-kernelcheck.patch
new file mode 100644
index 000000000..37418cc3f
--- /dev/null
+++ b/staging/xf86-video-vesa/revert-kernelcheck.patch
@@ -0,0 +1,31 @@
+From b1f7f190f9d4f2ab63d3e9ade3e7e04bb4b1f89f Mon Sep 17 00:00:00 2001
+From: Adam Jackson <ajax@redhat.com>
+Date: Wed, 08 Dec 2010 18:45:32 +0000
+Subject: Refuse to load if there's a kernel driver bound to the device
+
+Ported from the equivalent check in nv.
+
+Signed-off-by: Adam Jackson <ajax@redhat.com>
+---
+diff --git a/src/vesa.c b/src/vesa.c
+index 168fde1..2523d76 100644
+--- a/src/vesa.c
++++ b/src/vesa.c
+@@ -431,8 +431,14 @@ VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
+ pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+ if (pScrn != NULL) {
+- VESAPtr pVesa = VESAGetRec(pScrn);
++ VESAPtr pVesa;
+
++ if (pci_device_has_kernel_driver(dev)) {
++ ErrorF("vesa: Ignoring device with a bound kernel driver\n");
++ return FALSE;
++ }
++
++ pVesa = VESAGetRec(pScrn);
+ VESAInitScrn(pScrn);
+ pVesa->pciInfo = dev;
+ }
+--
+cgit v0.9.0.2-2-gbebe
diff --git a/staging/xf86-video-voodoo/PKGBUILD b/staging/xf86-video-voodoo/PKGBUILD
new file mode 100644
index 000000000..209f6a42e
--- /dev/null
+++ b/staging/xf86-video-voodoo/PKGBUILD
@@ -0,0 +1,30 @@
+# $Id: PKGBUILD 149900 2012-02-11 12:20:47Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-voodoo
+pkgver=1.2.4
+pkgrel=6
+pkgdesc="X.org 3dfx Voodoo1/Voodoo2 2D video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'xf86dgaproto')
+conflicts=('xorg-server<1.11.99.903')
+groups=('xorg-drivers' 'xorg')
+options=('!libtool')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2)
+sha1sums=('7ecd232cc0b7fe507e18e08799791eefa9fdaf48')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+}
diff --git a/staging/xf86-video-xgixp/PKGBUILD b/staging/xf86-video-xgixp/PKGBUILD
new file mode 100644
index 000000000..7027c85ba
--- /dev/null
+++ b/staging/xf86-video-xgixp/PKGBUILD
@@ -0,0 +1,33 @@
+# $Id: PKGBUILD 149902 2012-02-11 12:24:18Z andyrtr $
+# Maintainer: Jan de Groot <jgc@archlinux.org>
+
+pkgname=xf86-video-xgixp
+pkgver=1.8.0
+pkgrel=5
+pkgdesc="X.org XGIXP video driver"
+arch=(i686 x86_64)
+url="http://xorg.freedesktop.org/"
+license=('custom')
+depends=('glibc')
+makedepends=('xorg-server-devel>=1.11.99.903' 'libdrm' 'xf86driproto' 'mesa') # 'glproto')
+conflicts=('xorg-server<1.11.99.903')
+options=('!libtool')
+groups=('xorg-drivers' 'xorg')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ api-compat-fix-for-DRAWABLE_BUFFER.patch)
+sha1sums=('67caeaa4c746572160208fe23c7257f62cb442a3'
+ 'ea140a13963bbf33cdff1ad75789d765867ec53b')
+
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ patch -Np1 -i "${srcdir}/api-compat-fix-for-DRAWABLE_BUFFER.patch"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+ install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/"
+}
diff --git a/staging/xf86-video-xgixp/api-compat-fix-for-DRAWABLE_BUFFER.patch b/staging/xf86-video-xgixp/api-compat-fix-for-DRAWABLE_BUFFER.patch
new file mode 100644
index 000000000..f8cb64673
--- /dev/null
+++ b/staging/xf86-video-xgixp/api-compat-fix-for-DRAWABLE_BUFFER.patch
@@ -0,0 +1,23 @@
+From 86258a6fd8fc8bb09a52ee446b37abe6bd0843ef Mon Sep 17 00:00:00 2001
+From: Adam Jackson <ajax@redhat.com>
+Date: Fri, 25 Mar 2011 22:46:55 +0000
+Subject: API compat fix for DRAWABLE_BUFFER
+
+Signed-off-by: Adam Jackson <ajax@redhat.com>
+---
+diff --git a/src/xgi_driver.c b/src/xgi_driver.c
+index e54d8c7..189b84a 100644
+--- a/src/xgi_driver.c
++++ b/src/xgi_driver.c
+@@ -2708,7 +2708,9 @@ xg47_setup_fb_wrap(ReadMemoryProcPtr *read_ptr,
+ {
+ switch (pDraw->type) {
+ case DRAWABLE_WINDOW:
++#ifdef DRAWABLE_BUFFER
+ case DRAWABLE_BUFFER:
++#endif
+ *read_ptr = xg47_read_memory_swap_func;
+ *write_ptr = xg47_write_memory_swap_func;
+ break;
+--
+cgit v0.8.3-6-g21f6
diff --git a/staging/xorg-server/PKGBUILD b/staging/xorg-server/PKGBUILD
index 2c8f0cd3c..961dcd7ef 100644
--- a/staging/xorg-server/PKGBUILD
+++ b/staging/xorg-server/PKGBUILD
@@ -1,10 +1,10 @@
-# $Id: PKGBUILD 149765 2012-02-10 14:43:55Z ibiru $
+# $Id: PKGBUILD 149823 2012-02-11 09:09:10Z andyrtr $
# Maintainer: Jan de Groot <jgc@archlinux.org>
pkgbase=xorg-server
pkgname=('xorg-server' 'xorg-server-xephyr' 'xorg-server-xdmx' 'xorg-server-xvfb' 'xorg-server-xnest' 'xorg-server-common' 'xorg-server-devel')
-pkgver=1.11.99.902
-pkgrel=2
+pkgver=1.11.99.903
+pkgrel=1
arch=('i686' 'x86_64')
license=('custom')
url="http://xorg.freedesktop.org"
@@ -20,12 +20,12 @@ source=(${url}/releases/individual/xserver/${pkgbase}-${pkgver}.tar.bz2
xvfb-run
xvfb-run.1
10-quirks.conf)
-md5sums=('c1535e351dc73836a9000b7c9bc13112'
- '7adcd74aebad71af7cc7b68c35aaaf35'
- 'f8194638ca4872c2b0a67862a70bcebf'
- '52fd3effd80d7bc6c1660d4ecf23d31c'
- '376c70308715cd2643f7bff936d9934b'
- 'd4f7dfc6be4ef4e2c6dd7632a9d88abe')
+sha1sums=('a8058c22c2dc0388e64fa58e0307813cb72a337f'
+ 'f19658773d3fa4dc468bb28f9f01866acce71540'
+ '962fecc159c128728f14e8ba231c5b00391ff4ac'
+ 'c94f742d3f9cabf958ae58e4015d9dd185aabedc'
+ '6838fc00ef4618c924a77e0fb03c05346080908a'
+ '993798f3d22ad672d769dae5f48d1fa068d5578f')
build() {
cd "${srcdir}/${pkgbase}-${pkgver}"