All of lore.kernel.org
 help / color / mirror / Atom feed
* recipes/mesa cleanup
@ 2010-06-25 12:19 Martin Jansa
  2010-06-25 12:19 ` [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file Martin Jansa
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Hi,

i know the rules about removing old versions, but in this dir there were versions 
really old and I'm pretty sure they cant be even built with current OE (I tried in
few cases and then refused to spend whole day just to confirm that some 6.0 version 
still builds after converting to new staging and cleanups..).

Please review/test.

FYI: all those patches are often rebased on top of oe.dev also here 
http://gitorious.org/~jama/angstrom/jama-shr-experimental 
if cherry-picking is more effective way for you to test

Regards,




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-26  8:32   ` Frans Meulenbroeks
  2010-06-25 12:19 ` [PATCH 2/9] preferred-om-2008-versions: remove pinned version of mesa/mesa-dri Martin Jansa
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 recipes/mesa/mesa-6.0.1/Make-config.patch |   26 ---------------
 recipes/mesa/mesa-6.0.1/mklib.patch       |   22 -------------
 recipes/mesa/mesa_6.0.1.bb                |   29 -----------------
 recipes/mesa/mesa_6.4.1+cvs20060101.bb    |   48 -----------------------------
 4 files changed, 0 insertions(+), 125 deletions(-)
 delete mode 100644 recipes/mesa/mesa-6.0.1/Make-config.patch
 delete mode 100644 recipes/mesa/mesa-6.0.1/mklib.patch
 delete mode 100644 recipes/mesa/mesa_6.0.1.bb
 delete mode 100644 recipes/mesa/mesa_6.4.1+cvs20060101.bb

diff --git a/recipes/mesa/mesa-6.0.1/Make-config.patch b/recipes/mesa/mesa-6.0.1/Make-config.patch
deleted file mode 100644
index cfe8890..0000000
--- a/recipes/mesa/mesa-6.0.1/Make-config.patch
+++ /dev/null
@@ -1,26 +0,0 @@
---- mesa/Make-config.orig	2004-06-25 13:09:44.000000000 +0100
-+++ mesa/Make-config	2004-06-25 14:18:27.000000000 +0100
-@@ -643,16 +643,16 @@
- 	"GLUT_LIB = libglut.so" \
- 	"GLW_LIB = libGLw.so" \
- 	"OSMESA_LIB = libOSMesa.so" \
--	"CC = gcc" \
--	"CXX = g++" \
--	"CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include" \
--	"CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE" \
-+	"CC = $(CC)" \
-+	"CXX = $(CXX)" \
-+	"CFLAGS = -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS $(CFLAGS)" \
-+	"CXXFLAGS = -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE $(CXXFLAGS)" \
- 	"GLUT_CFLAGS = -fexceptions" \
--	"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread" \
-+	"GL_LIB_DEPS = $(LDFLAGS) -lX11 -lXext -lm -lpthread" \
- 	"OSMESA_LIB_DEPS = -L$(TOP)/lib -lGL" \
- 	"GLU_LIB_DEPS = -L$(TOP)/lib -lGL -lm" \
--	"GLUT_LIB_DEPS = -L$(TOP)/lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
--	"GLW_LIB_DEPS = -L$(TOP)/lib -lGL -L/usr/X11R6/lib -lXt -lX11" \
-+	"GLUT_LIB_DEPS = $(LDFLAGS) -L$(TOP)/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm" \
-+	"GLW_LIB_DEPS = $(LDFLAGS) -L$(TOP)/lib -lGL -lXt -lX11" \
- 	"APP_LIB_DEPS = -lglut -lGLU -lGL -lm"
- 
- linux-static:
diff --git a/recipes/mesa/mesa-6.0.1/mklib.patch b/recipes/mesa/mesa-6.0.1/mklib.patch
deleted file mode 100644
index 7dc1ec7..0000000
--- a/recipes/mesa/mesa-6.0.1/mklib.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- mesa/bin/mklib.old	2004-06-25 14:08:41.000000000 +0100
-+++ mesa/bin/mklib	2004-06-25 14:23:09.000000000 +0100
-@@ -64,6 +64,7 @@
- 	'-install')   shift 1; INSTALLDIR=$1;;
- 	'-arch')      shift 1; ARCH=$1;;
- 	'-archopt')   shift 1; ARCHOPT=$1;;
-+	-Wl*)	      DEPS="$DEPS $1";;
- 	-*)           echo "mklib: Unknown option: " $1 ; exit 1;;
- 	*) break
-     esac
-@@ -137,9 +138,9 @@
-             echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
- 
-             if [ $CPLUSPLUS = 1 ] ; then
--                LINK="g++"
-+                LINK="$CXX"
-             else
--                LINK="gcc"
-+                LINK="$CC"
-             fi
- 
-             # rm any old libs
diff --git a/recipes/mesa/mesa_6.0.1.bb b/recipes/mesa/mesa_6.0.1.bb
deleted file mode 100644
index 3b37b8f..0000000
--- a/recipes/mesa/mesa_6.0.1.bb
+++ /dev/null
@@ -1,29 +0,0 @@
-SECTION = "unknown"
-SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2 \
-	file://Make-config.patch \
-	file://mklib.patch"
-S = "${WORKDIR}/Mesa-${PV}"
-PE = "2"
-LICENSE = "LGPL"
-# gcc-3.4 blows up in gtktext with -frename-registers on arm-linux
-CXXFLAGS := "${@'${CXXFLAGS}'.replace('-frename-registers', '')}"
-DEPENDS = "makedepend-native"
-
-do_compile() {
-	oe_runmake linux CC="${CC}" CXX="${CXX}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LD="${LD}" LDFLAGS="${LDFLAGS}"
-}
-
-do_install() {
-	install -d ${D}${libdir}
-	cp -pP lib/* ${D}${libdir}/
-	install -d ${D}${includedir}
-	cp -R include/GL ${D}${includedir}/
-}
-
-do_stage() {
-        cp -pP lib/* ${STAGING_LIBDIR}/
-        cp -R include/GL ${STAGING_INCDIR}/
-}
-
-SRC_URI[md5sum] = "b7f14088c5c2f14490d2739a91102112"
-SRC_URI[sha256sum] = "2de039f7abe10569b681ea1d9e21fb65fd0081c8f4db40fb62b332acb11679fb"
diff --git a/recipes/mesa/mesa_6.4.1+cvs20060101.bb b/recipes/mesa/mesa_6.4.1+cvs20060101.bb
deleted file mode 100644
index 9fceca1..0000000
--- a/recipes/mesa/mesa_6.4.1+cvs20060101.bb
+++ /dev/null
@@ -1,48 +0,0 @@
-SECTION = "unknown"
-
-SRCDATE = "20060101"
-PV = "6.4.1+cvs${SRCDATE}"
-PE = "2"
-PR = "r1"
-
-SRC_URI = "${FREEDESKTOP_CVS}/mesa;module=Mesa;method=pserver;date=${SRCDATE} \
-	file://mklib-rpath-link.patch"
-S = "${WORKDIR}/Mesa"
-
-LICENSE = "LGPL"
-
-RDEPENDS_${PN} = "expat"
-DEPENDS = "makedepend-native xf86vidmodeproto glproto virtual/libx11 libxext libxxf86vm libxi libxmu libice"
-
-# gcc-3.4 blows up in gtktext with -frename-registers on arm-linux
-CXXFLAGS := "${@'${CXXFLAGS}'.replace('-frename-registers', '')}"
-
-do_configure() {
-	cd configs
-
-	ln -sf linux current
-	sed -e "s%CC *= *.*%CC = ${CC}%" -i current
-	sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
-	sed -e "s%LD *= *.*%LD = ${LD}%" -i current
-	sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
-	sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
-	sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
-	sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
-	echo "SRC_DIRS = mesa glu glut/glx" >> current
-}
-
-do_compile() {
-	oe_runmake default
-}
-
-do_install() {
-	install -d ${D}${libdir}
-	cp -pP lib/* ${D}${libdir}/
-	install -d ${D}${includedir}
-	cp -R include/GL ${D}${includedir}/
-}
-
-do_stage() {
-        cp -pP lib/* ${STAGING_LIBDIR}/
-        cp -R include/GL ${STAGING_INCDIR}/
-}
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/9] preferred-om-2008-versions: remove pinned version of mesa/mesa-dri
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
  2010-06-25 12:19 ` [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-25 12:19 ` [PATCH 3/9] mesa: remove old releases 6.5.2, 7.0.2 using mesa-mesa.inc Martin Jansa
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 conf/distro/include/preferred-om-2008-versions.inc |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/conf/distro/include/preferred-om-2008-versions.inc b/conf/distro/include/preferred-om-2008-versions.inc
index 3020fe9..79dde2e 100644
--- a/conf/distro/include/preferred-om-2008-versions.inc
+++ b/conf/distro/include/preferred-om-2008-versions.inc
@@ -1196,8 +1196,6 @@ PREFERRED_VERSION_mdev ?= "1.2.1"
 PREFERRED_VERSION_mdk2 ?= "v33"
 PREFERRED_VERSION_memedit ?= "0.7"
 PREFERRED_VERSION_memtester ?= "4.0.6"
-PREFERRED_VERSION_mesa ?= "6.5.2"
-PREFERRED_VERSION_mesa-dri ?= "6.5.2"
 PREFERRED_VERSION_meta-e-x11 ?= "1.0"
 PREFERRED_VERSION_meta-e-x11-core ?= "1.0"
 PREFERRED_VERSION_meta-gpe ?= "1.0"
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/9] mesa: remove old releases 6.5.2, 7.0.2 using mesa-mesa.inc
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
  2010-06-25 12:19 ` [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file Martin Jansa
  2010-06-25 12:19 ` [PATCH 2/9] preferred-om-2008-versions: remove pinned version of mesa/mesa-dri Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-25 12:19 ` [PATCH 4/9] mesa-dri: remove old 7.0.3 and 6.5.2 relase using mesa-common-old.inc Martin Jansa
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 recipes/mesa/mesa-6.5.2/fix-host-compile.patch     |   30 ---------
 recipes/mesa/mesa-6.5.2/mklib-rpath-link.patch     |   23 -------
 recipes/mesa/mesa-7.0.2/fix-host-compile.patch     |   30 ---------
 recipes/mesa/mesa-7.0.2/mklib-rpath-link.patch     |   23 -------
 .../mesa/mesa-full-7.0.2/fix-host-compile.patch    |   30 ---------
 .../mesa/mesa-full-7.0.2/fix-progs-makefile.patch  |   65 --------------------
 .../mesa/mesa-full-7.0.2/mklib-rpath-link.patch    |   23 -------
 recipes/mesa/mesa-full_7.0.2.bb                    |   27 --------
 recipes/mesa/mesa-mesa.inc                         |   41 ------------
 recipes/mesa/mesa_6.5.2.bb                         |    8 ---
 recipes/mesa/mesa_7.0.2.bb                         |    8 ---
 11 files changed, 0 insertions(+), 308 deletions(-)
 delete mode 100644 recipes/mesa/mesa-6.5.2/fix-host-compile.patch
 delete mode 100644 recipes/mesa/mesa-6.5.2/mklib-rpath-link.patch
 delete mode 100644 recipes/mesa/mesa-7.0.2/fix-host-compile.patch
 delete mode 100644 recipes/mesa/mesa-7.0.2/mklib-rpath-link.patch
 delete mode 100644 recipes/mesa/mesa-full-7.0.2/fix-host-compile.patch
 delete mode 100644 recipes/mesa/mesa-full-7.0.2/fix-progs-makefile.patch
 delete mode 100644 recipes/mesa/mesa-full-7.0.2/mklib-rpath-link.patch
 delete mode 100644 recipes/mesa/mesa-full_7.0.2.bb
 delete mode 100644 recipes/mesa/mesa-mesa.inc
 delete mode 100644 recipes/mesa/mesa_6.5.2.bb
 delete mode 100644 recipes/mesa/mesa_7.0.2.bb

diff --git a/recipes/mesa/mesa-6.5.2/fix-host-compile.patch b/recipes/mesa/mesa-6.5.2/fix-host-compile.patch
deleted file mode 100644
index d24d03d..0000000
--- a/recipes/mesa/mesa-6.5.2/fix-host-compile.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- /src/mesa/x86/orig-Makefile	2005-07-01 04:54:38.000000000 +0300
-+++ /src/mesa/x86/Makefile	2007-06-07 21:52:31.000000000 +0300
-@@ -5,6 +5,7 @@
- 
- 
- INCLUDE_DIRS = \
-+        -I/usr/include \
- 	-I$(TOP)/include/GL \
- 	-I$(TOP)/include \
- 	-I.. \
-@@ -13,6 +14,10 @@
- 	-I../glapi \
- 	-I../tnl
- 
-+OPT_FLAGS_host = -fexpensive-optimizations -fomit-frame-pointer -frename-registers -Os
-+
-+CFLAGS_host = -Wall -Wmissing-prototypes $(OPT_FLAGS_host) $(PIC_FLAGS) $(ARCH_FLAGS) \
-+        $(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
- 
- default: gen_matypes matypes.h
- 
-@@ -21,7 +26,7 @@
- 
- 
- gen_matypes: gen_matypes.c
--	$(CC) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c -o gen_matypes
-+	$(CC) $(INCLUDE_DIRS) $(CFLAGS_host) gen_matypes.c -o gen_matypes
- 
- # need some special rules here, unfortunately
- matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
diff --git a/recipes/mesa/mesa-6.5.2/mklib-rpath-link.patch b/recipes/mesa/mesa-6.5.2/mklib-rpath-link.patch
deleted file mode 100644
index e59513a..0000000
--- a/recipes/mesa/mesa-6.5.2/mklib-rpath-link.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- Mesa/bin/mklib.orig	2006-06-04 20:56:22.000000000 -0600
-+++ Mesa/bin/mklib	2006-06-04 20:57:04.000000000 -0600
-@@ -98,6 +98,9 @@
- 	-L*)
- 	    DEPS="$DEPS $1"
- 	    ;;
-+	-Wl*)
-+	    DEPS="$DEPS $1"
-+	    ;;
- 	'-cplusplus')
- 	    CPLUSPLUS=1
- 	    ;;
---- Mesa-6.5.2/configs/default.old	2007-01-26 11:49:32.000000000 +0000
-+++ Mesa-6.5.2/configs/default	2007-01-26 11:49:49.000000000 +0000
-@@ -73,7 +73,7 @@
- GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
- GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
- GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
--APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
-+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) $(EXTRA_LIB_PATH) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
- 
- 
- 
diff --git a/recipes/mesa/mesa-7.0.2/fix-host-compile.patch b/recipes/mesa/mesa-7.0.2/fix-host-compile.patch
deleted file mode 100644
index d24d03d..0000000
--- a/recipes/mesa/mesa-7.0.2/fix-host-compile.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- /src/mesa/x86/orig-Makefile	2005-07-01 04:54:38.000000000 +0300
-+++ /src/mesa/x86/Makefile	2007-06-07 21:52:31.000000000 +0300
-@@ -5,6 +5,7 @@
- 
- 
- INCLUDE_DIRS = \
-+        -I/usr/include \
- 	-I$(TOP)/include/GL \
- 	-I$(TOP)/include \
- 	-I.. \
-@@ -13,6 +14,10 @@
- 	-I../glapi \
- 	-I../tnl
- 
-+OPT_FLAGS_host = -fexpensive-optimizations -fomit-frame-pointer -frename-registers -Os
-+
-+CFLAGS_host = -Wall -Wmissing-prototypes $(OPT_FLAGS_host) $(PIC_FLAGS) $(ARCH_FLAGS) \
-+        $(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
- 
- default: gen_matypes matypes.h
- 
-@@ -21,7 +26,7 @@
- 
- 
- gen_matypes: gen_matypes.c
--	$(CC) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c -o gen_matypes
-+	$(CC) $(INCLUDE_DIRS) $(CFLAGS_host) gen_matypes.c -o gen_matypes
- 
- # need some special rules here, unfortunately
- matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
diff --git a/recipes/mesa/mesa-7.0.2/mklib-rpath-link.patch b/recipes/mesa/mesa-7.0.2/mklib-rpath-link.patch
deleted file mode 100644
index 618f5b5..0000000
--- a/recipes/mesa/mesa-7.0.2/mklib-rpath-link.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- /tmp/mklib	2007-12-08 11:03:23.000000000 +0100
-+++ Mesa-7.0.2/bin/mklib	2007-12-08 11:04:02.509863000 +0100
-@@ -106,6 +106,9 @@
- 	-L*)
- 	    DEPS="$DEPS $1"
- 	    ;;
-+        -Wl*)
-+            DEPS="$DEPS $1"
-+            ;;
- 	-pthread)
- 	    # this is a special case (see bugzilla 10876)
- 	    DEPS="$DEPS $1"
---- /tmp/default	2007-12-08 11:04:17.000000000 +0100
-+++ Mesa-7.0.2/configs/default	2007-12-08 11:05:06.279863000 +0100
-@@ -76,7 +76,7 @@
- GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
- 
- # Program dependencies - specific GL/glut libraries added in Makefiles
--APP_LIB_DEPS = -lm
-+APP_LIB_DEPS = $(EXTRA_LIB_PATH) -lm
- 
- 
- 
diff --git a/recipes/mesa/mesa-full-7.0.2/fix-host-compile.patch b/recipes/mesa/mesa-full-7.0.2/fix-host-compile.patch
deleted file mode 100644
index d24d03d..0000000
--- a/recipes/mesa/mesa-full-7.0.2/fix-host-compile.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- /src/mesa/x86/orig-Makefile	2005-07-01 04:54:38.000000000 +0300
-+++ /src/mesa/x86/Makefile	2007-06-07 21:52:31.000000000 +0300
-@@ -5,6 +5,7 @@
- 
- 
- INCLUDE_DIRS = \
-+        -I/usr/include \
- 	-I$(TOP)/include/GL \
- 	-I$(TOP)/include \
- 	-I.. \
-@@ -13,6 +14,10 @@
- 	-I../glapi \
- 	-I../tnl
- 
-+OPT_FLAGS_host = -fexpensive-optimizations -fomit-frame-pointer -frename-registers -Os
-+
-+CFLAGS_host = -Wall -Wmissing-prototypes $(OPT_FLAGS_host) $(PIC_FLAGS) $(ARCH_FLAGS) \
-+        $(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
- 
- default: gen_matypes matypes.h
- 
-@@ -21,7 +26,7 @@
- 
- 
- gen_matypes: gen_matypes.c
--	$(CC) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c -o gen_matypes
-+	$(CC) $(INCLUDE_DIRS) $(CFLAGS_host) gen_matypes.c -o gen_matypes
- 
- # need some special rules here, unfortunately
- matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
diff --git a/recipes/mesa/mesa-full-7.0.2/fix-progs-makefile.patch b/recipes/mesa/mesa-full-7.0.2/fix-progs-makefile.patch
deleted file mode 100644
index 727ede0..0000000
--- a/recipes/mesa/mesa-full-7.0.2/fix-progs-makefile.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-Index: Mesa-7.0.2/progs/demos/Makefile
-===================================================================
---- Mesa-7.0.2.orig/progs/demos/Makefile	2008-08-22 15:52:16.000000000 +0800
-+++ Mesa-7.0.2/progs/demos/Makefile	2008-08-22 15:52:33.000000000 +0800
-@@ -13,7 +13,7 @@
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lstdc++
- 
- PROGS = \
- 	arbfplight \
-Index: Mesa-7.0.2/progs/glsl/Makefile
-===================================================================
---- Mesa-7.0.2.orig/progs/glsl/Makefile	2008-08-22 15:56:37.000000000 +0800
-+++ Mesa-7.0.2/progs/glsl/Makefile	2008-08-22 15:56:52.000000000 +0800
-@@ -7,7 +7,7 @@
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lstdc++
- 
- PROGS = \
- 	brick \
-Index: Mesa-7.0.2/progs/redbook/Makefile
-===================================================================
---- Mesa-7.0.2.orig/progs/redbook/Makefile	2008-08-22 15:55:10.000000000 +0800
-+++ Mesa-7.0.2/progs/redbook/Makefile	2008-08-22 15:55:27.000000000 +0800
-@@ -7,7 +7,7 @@
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lstdc++
- 
- PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
- 	bezcurve bezmesh checker clip colormat cube depthcue dof \
-Index: Mesa-7.0.2/progs/samples/Makefile
-===================================================================
---- Mesa-7.0.2.orig/progs/samples/Makefile	2008-08-22 15:56:01.000000000 +0800
-+++ Mesa-7.0.2/progs/samples/Makefile	2008-08-22 15:56:13.000000000 +0800
-@@ -7,7 +7,7 @@
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lstdc++
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim quad select \
-Index: Mesa-7.0.2/progs/xdemos/Makefile
-===================================================================
---- Mesa-7.0.2.orig/progs/xdemos/Makefile	2008-08-22 15:57:11.000000000 +0800
-+++ Mesa-7.0.2/progs/xdemos/Makefile	2008-08-22 15:57:22.000000000 +0800
-@@ -8,7 +8,7 @@
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) -lstdc++
- 
- PROGS = glthreads \
- 	glxdemo \
diff --git a/recipes/mesa/mesa-full-7.0.2/mklib-rpath-link.patch b/recipes/mesa/mesa-full-7.0.2/mklib-rpath-link.patch
deleted file mode 100644
index 618f5b5..0000000
--- a/recipes/mesa/mesa-full-7.0.2/mklib-rpath-link.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- /tmp/mklib	2007-12-08 11:03:23.000000000 +0100
-+++ Mesa-7.0.2/bin/mklib	2007-12-08 11:04:02.509863000 +0100
-@@ -106,6 +106,9 @@
- 	-L*)
- 	    DEPS="$DEPS $1"
- 	    ;;
-+        -Wl*)
-+            DEPS="$DEPS $1"
-+            ;;
- 	-pthread)
- 	    # this is a special case (see bugzilla 10876)
- 	    DEPS="$DEPS $1"
---- /tmp/default	2007-12-08 11:04:17.000000000 +0100
-+++ Mesa-7.0.2/configs/default	2007-12-08 11:05:06.279863000 +0100
-@@ -76,7 +76,7 @@
- GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
- 
- # Program dependencies - specific GL/glut libraries added in Makefiles
--APP_LIB_DEPS = -lm
-+APP_LIB_DEPS = $(EXTRA_LIB_PATH) -lm
- 
- 
- 
diff --git a/recipes/mesa/mesa-full_7.0.2.bb b/recipes/mesa/mesa-full_7.0.2.bb
deleted file mode 100644
index 2f98eed..0000000
--- a/recipes/mesa/mesa-full_7.0.2.bb
+++ /dev/null
@@ -1,27 +0,0 @@
-include mesa-mesa.inc
-
-SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2;name=archive \
-        ${SOURCEFORGE_MIRROR}/mesa3d/MesaGLUT-${PV}.tar.bz2;name=glut \
-        ${SOURCEFORGE_MIRROR}/mesa3d/MesaDemos-${PV}.tar.bz2;name=demos \
-        file://mklib-rpath-link.patch \
-        file://fix-host-compile.patch \
-        file://fix-progs-makefile.patch \
-        "
-
-do_install_append = "install -d ${D}${bindir}; \
-                     for f in glxgears glxheads glxdemo glxinfo; do \
-                     cp progs/xdemos/${f} ${D}${bindir}; \
-                     done"
-
-PACKAGES =+ "libglut libglut-dev mesa-utils"
-
-FILES_libglut = "${libdir}/libglut.so.*"
-FILES_libglut-dev = "${libdir}/libglut.* ${includedir}/GL/glut*"
-FILES_mesa-utils = "${bindir}/*"
-
-SRC_URI[archive.md5sum] = "93e6ed7924ff069a4f883b4fce5349dc"
-SRC_URI[archive.sha256sum] = "9d4707b556960f6aef14480f91fcd4f868720f64321947ab1b2fd20e85ce7f9e"
-SRC_URI[glut.md5sum] = "3a33f8efc8c58a592a854cfc7a643286"
-SRC_URI[glut.sha256sum] = "fa31ca39f00ff92c7da59d9993d0eefb8d901eb8a519743942e523fde120eb6c"
-SRC_URI[demos.md5sum] = "11a10410bae7be85cf25bc7119966468"
-SRC_URI[demos.sha256sum] = "ce39b26085acd8e5dffa8233618acac2605cc42203bc4f81c6e4504265f0ffaa"
diff --git a/recipes/mesa/mesa-mesa.inc b/recipes/mesa/mesa-mesa.inc
deleted file mode 100644
index 48d171d..0000000
--- a/recipes/mesa/mesa-mesa.inc
+++ /dev/null
@@ -1,41 +0,0 @@
-include mesa-common-old.inc
-
-PACKAGES =+ "libglu libglu-dev libosmesa libosmesa-dev libgl libgl-dev"
-
-FILES_libgl = "${libdir}/libGL.so.*"
-FILES_libglu = "${libdir}/libGLU.so.*"
-FILES_libosmesa = "${libdir}/libOSMesa.so.*"
-
-FILES_libgl-dev = "${libdir}/libGL.* ${includedir}/GL"
-FILES_libglu-dev = "${libdir}/libGLU.* ${includedir}/GL/glu*.h"
-FILES_libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/osmesa.h"
-
-do_configure() {
-	cd configs
-
-	cp linux current
-	sed -e "s%CC *= *.*%CC = ${CC}%" -i current
-	sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
-	sed -e "s%LD *= *.*%LD = ${LD}%" -i current
-	sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
-	sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
-	sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
-	sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
-	echo "SRC_DIRS = mesa glu glut/glx" >> current
-}
-
-do_compile() {
-	oe_runmake default
-}
-
-do_install() {
-	install -d ${D}${libdir}
-	cp -pP lib/* ${D}${libdir}/
-	install -d ${D}${includedir}
-	cp -R include/GL ${D}${includedir}/
-}
-
-do_stage() {
-        cp -pP lib/* ${STAGING_LIBDIR}/
-        cp -R include/GL ${STAGING_INCDIR}/
-}
diff --git a/recipes/mesa/mesa_6.5.2.bb b/recipes/mesa/mesa_6.5.2.bb
deleted file mode 100644
index 8573ce3..0000000
--- a/recipes/mesa/mesa_6.5.2.bb
+++ /dev/null
@@ -1,8 +0,0 @@
-include mesa-mesa.inc
-
-PR = "${INC_PR}.0"
-
-SRC_URI_append = " file://fix-host-compile.patch "
-
-SRC_URI[md5sum] = "e4d894181f1859651658b3704633e10d"
-SRC_URI[sha256sum] = "137f50a30461d51eb9af5aac737bc788d536354cf47b26129b97bde6e41fb85f"
diff --git a/recipes/mesa/mesa_7.0.2.bb b/recipes/mesa/mesa_7.0.2.bb
deleted file mode 100644
index 96dd966..0000000
--- a/recipes/mesa/mesa_7.0.2.bb
+++ /dev/null
@@ -1,8 +0,0 @@
-include mesa-mesa.inc
-
-PR = "${INC_PR}.0"
-
-SRC_URI_append = " file://fix-host-compile.patch "
-
-SRC_URI[md5sum] = "93e6ed7924ff069a4f883b4fce5349dc"
-SRC_URI[sha256sum] = "9d4707b556960f6aef14480f91fcd4f868720f64321947ab1b2fd20e85ce7f9e"
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/9] mesa-dri: remove old 7.0.3 and 6.5.2 relase using mesa-common-old.inc
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (2 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 3/9] mesa: remove old releases 6.5.2, 7.0.2 using mesa-mesa.inc Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-26  8:33   ` Frans Meulenbroeks
  2010-06-25 12:19 ` [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in any distro/include config Martin Jansa
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 recipes/mesa/files/fix-progs-makefile.patch |   81 ---------------------------
 recipes/mesa/files/mklib-cross.patch        |   14 -----
 recipes/mesa/files/mklib-rpath-link.patch   |   20 -------
 recipes/mesa/mesa-common-old.inc            |   15 -----
 recipes/mesa/mesa-dri_6.5.2.bb              |   44 --------------
 recipes/mesa/mesa-dri_7.0.3.bb              |   45 ---------------
 6 files changed, 0 insertions(+), 219 deletions(-)
 delete mode 100644 recipes/mesa/files/fix-progs-makefile.patch
 delete mode 100644 recipes/mesa/files/mklib-cross.patch
 delete mode 100644 recipes/mesa/files/mklib-rpath-link.patch
 delete mode 100644 recipes/mesa/mesa-common-old.inc
 delete mode 100644 recipes/mesa/mesa-dri_6.5.2.bb
 delete mode 100644 recipes/mesa/mesa-dri_7.0.3.bb

diff --git a/recipes/mesa/files/fix-progs-makefile.patch b/recipes/mesa/files/fix-progs-makefile.patch
deleted file mode 100644
index f0a8293..0000000
--- a/recipes/mesa/files/fix-progs-makefile.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
-From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Thu, 4 Mar 2010 14:16:27 +0100
-Subject: [PATCH] fix libs
-
----
- progs/demos/Makefile   |    2 +-
- progs/glsl/Makefile    |    2 +-
- progs/redbook/Makefile |    2 +-
- progs/samples/Makefile |    2 +-
- progs/xdemos/Makefile  |    2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index 5b1d2a0..121b862 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
- 	$(APP_LIB_DEPS)
- 
- PROGS = \
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 3b5a595..836c4ac 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -10,7 +10,7 @@ LIB_DEP = \
- 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
- 	-l$(GL_LIB) $(APP_LIB_DEPS)
- 
- # using : to avoid APP_CC pointing to CC loop
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index b41e488..95ed746 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = aaindex \
- 	aapoly \
-diff --git a/progs/samples/Makefile b/progs/samples/Makefile
-index 64fa47a..9f72c8b 100644
---- a/progs/samples/Makefile
-+++ b/progs/samples/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
-diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
-index f866a32..c0f4e06 100644
---- a/progs/xdemos/Makefile
-+++ b/progs/xdemos/Makefile
-@@ -11,7 +11,7 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
- # Add X11 and pthread libs to satisfy GNU gold.
- APP_LIB_DEPS += -lX11 -lpthread
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = \
- 	corender \
--- 
-1.7.0
-
diff --git a/recipes/mesa/files/mklib-cross.patch b/recipes/mesa/files/mklib-cross.patch
deleted file mode 100644
index fbe86e3..0000000
--- a/recipes/mesa/files/mklib-cross.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- s/bin/mklib~	2008-02-19 15:30:18.000000000 +0000
-+++ s/bin/mklib	2008-07-27 11:15:25.000000000 +0100
-@@ -204,9 +204,9 @@
- 	if [ "x$LINK" = "x" ] ; then
- 	    # -linker was not specified so set default link command now
-             if [ $CPLUSPLUS = 1 ] ; then
--                LINK=g++
-+                LINK=$CXX
-             else
--                LINK=gcc
-+                LINK=$CC
-             fi
- 	fi
- 
diff --git a/recipes/mesa/files/mklib-rpath-link.patch b/recipes/mesa/files/mklib-rpath-link.patch
deleted file mode 100644
index 07361f5..0000000
--- a/recipes/mesa/files/mklib-rpath-link.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- Mesa/bin/mklib.orig	2006-06-04 20:56:22.000000000 -0600
-+++ Mesa/bin/mklib	2006-06-04 20:57:04.000000000 -0600
-@@ -98,6 +98,9 @@
- 	-L*)
- 	    DEPS="$DEPS $1"
- 	    ;;
-+	-Wl*)
-+	    DEPS="$DEPS $1"
-+	    ;;
- 	'-cplusplus')
- 	    CPLUSPLUS=1
- 	    ;;
---- Mesa/configs/default.orig	2006-06-04 21:01:47.000000000 -0600
-+++ Mesa/configs/default	2006-06-04 21:01:16.000000000 -0600
-@@ -71,4 +71,4 @@
- GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
- GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
- GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
--APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
-+APP_LIB_DEPS = -L$(LIB_DIR) $(EXTRA_LIB_PATH) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/recipes/mesa/mesa-common-old.inc b/recipes/mesa/mesa-common-old.inc
deleted file mode 100644
index 01f0adc..0000000
--- a/recipes/mesa/mesa-common-old.inc
+++ /dev/null
@@ -1,15 +0,0 @@
-SECTION = "x11"
-PE = "2"
-
-SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2 \
-	file://mklib-rpath-link.patch"
-
-S = "${WORKDIR}/Mesa-${PV}"
-
-PROVIDES = "virtual/libgl"
-
-LICENSE = "LGPL"
-
-INC_PR = "r3"
-
-DEPENDS = "makedepend-native xf86vidmodeproto glproto virtual/libx11 libxext libxxf86vm libxi libxmu libice"
diff --git a/recipes/mesa/mesa-dri_6.5.2.bb b/recipes/mesa/mesa-dri_6.5.2.bb
deleted file mode 100644
index d8f9506..0000000
--- a/recipes/mesa/mesa-dri_6.5.2.bb
+++ /dev/null
@@ -1,44 +0,0 @@
-include mesa-common-old.inc
-
-SRC_URI += " file://mklib-cross.patch"
-
-FILESPATHPKG =. "mesa-${PV}:"
-
-PACKAGES_DYNAMIC = "mesa-dri-driver-*"
-
-PR = "${INC_PR}.1"
-
-DEPENDS += "libdrm"
-# DRI is useless without the kernel drivers
-RRECOMMENDS_${PN} += " kernel-module-drm kernel-module-radeon "
-
-do_configure() {
-	cd configs
-
-	ln -sf linux-dri current
-	sed -e "s%CC *= *.*%CC = ${CC}%" -i current
-	sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
-	sed -e "s%LD *= *.*%LD = ${LD}%" -i current
-	sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
-	sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
-	sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
-	sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
-	echo "SRC_DIRS = mesa" >> current
-	echo "DRI_DRIVER_INSTALL_DIR = ${D}${libdir}/dri" >> current
-}
-
-do_install() {
-	oe_runmake -C src/mesa/drivers/dri install
-}
-
-FILES_${PN}-dbg += "${libdir}/dri/.debug"
-
-python populate_packages_prepend () {
-        import re, os.path
-
-        do_split_packages(d, root=bb.data.expand('${libdir}/dri', d), file_regex='(.*)_dri\.so', output_pattern='mesa-dri-driver-%s', description='%s DRI driver', extra_depends='')
-}
-
-
-SRC_URI[md5sum] = "e4d894181f1859651658b3704633e10d"
-SRC_URI[sha256sum] = "137f50a30461d51eb9af5aac737bc788d536354cf47b26129b97bde6e41fb85f"
diff --git a/recipes/mesa/mesa-dri_7.0.3.bb b/recipes/mesa/mesa-dri_7.0.3.bb
deleted file mode 100644
index dcf6fd3..0000000
--- a/recipes/mesa/mesa-dri_7.0.3.bb
+++ /dev/null
@@ -1,45 +0,0 @@
-include mesa-common-old.inc
-
-# suppress mklib-rpath-link patch from mesa-common
-SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2 file://mklib-cross.patch"
-
-FILESPATHPKG =. "mesa-${PV}:"
-
-PACKAGES_DYNAMIC = "mesa-dri-driver-*"
-
-PR = "${INC_PR}.1"
-
-DEPENDS += "libdrm"
-# DRI is useless without the kernel drivers
-RRECOMMENDS_${PN} += " kernel-module-drm kernel-module-radeon "
-
-do_configure() {
-	cd configs
-
-	ln -sf linux-dri current
-	sed -e "s%CC *= *.*%CC = ${CC}%" -i current
-	sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
-	sed -e "s%LD *= *.*%LD = ${LD}%" -i current
-	sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
-	sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
-	sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
-	sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
-	echo "SRC_DIRS = mesa" >> current
-	echo "DRI_DRIVER_INSTALL_DIR = ${D}${libdir}/dri" >> current
-}
-
-do_install() {
-	oe_runmake -C src/mesa/drivers/dri install
-}
-
-FILES_${PN}-dbg += "${libdir}/dri/.debug"
-
-python populate_packages_prepend () {
-        import re, os.path
-
-        do_split_packages(d, root=bb.data.expand('${libdir}/dri', d), file_regex='(.*)_dri\.so', output_pattern='mesa-dri-driver-%s', description='%s DRI driver', extra_depends='')
-}
-
-
-SRC_URI[md5sum] = "e6e6379d7793af40a6bc3ce1bace572e"
-SRC_URI[sha256sum] = "ebdf3448eac8abb56bbfc0b7c015efce8e5d88f10ee3123dcc62c1ff47b62d22"
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in any distro/include config
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (3 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 4/9] mesa-dri: remove old 7.0.3 and 6.5.2 relase using mesa-common-old.inc Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-26  8:33   ` Frans Meulenbroeks
  2010-06-25 12:19 ` [PATCH 6/9] mesa: move 7.8 release to latest minor 7.8.2 Martin Jansa
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 recipes/mesa/mesa-dri_7.4.bb  |   27 ---------------------------
 recipes/mesa/mesa-xlib_7.4.bb |   24 ------------------------
 recipes/mesa/mesa_7.4.bb      |    2 --
 3 files changed, 0 insertions(+), 53 deletions(-)
 delete mode 100644 recipes/mesa/mesa-dri_7.4.bb
 delete mode 100644 recipes/mesa/mesa-xlib_7.4.bb
 delete mode 100644 recipes/mesa/mesa_7.4.bb

diff --git a/recipes/mesa/mesa-dri_7.4.bb b/recipes/mesa/mesa-dri_7.4.bb
deleted file mode 100644
index a78c03f..0000000
--- a/recipes/mesa/mesa-dri_7.4.bb
+++ /dev/null
@@ -1,27 +0,0 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto expat"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
-PR = "${INC_PR}.0"
-
-# most of our targets do not have DRI so will use mesa-xlib
-DEFAULT_PREFERENCE = "-1"
-
-# ASUS EeePC 901 has DRI support so use mesa-dri by default
-DEFAULT_PREFERENCE_eee901 = "1"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN} += "${libdir}/dri/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-EXTRA_OECONF += "--with-driver=dri --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-
-SRC_URI[archive.md5sum] = "7ecddb341a2691e0dfdb02f697109834"
-SRC_URI[archive.sha256sum] = "6e945389add4e5b41f2c403ced13c343767565f2eacde4b16de2d0f9f8a6aac4"
-SRC_URI[demos.md5sum] = "02816f10f30b1dc5e069e0f68c177c98"
-SRC_URI[demos.sha256sum] = "c3de74d62f925e32030adb3d0edcfb3c7a4129fc92c48181a389eeed8f14b897"
diff --git a/recipes/mesa/mesa-xlib_7.4.bb b/recipes/mesa/mesa-xlib_7.4.bb
deleted file mode 100644
index 68e7218..0000000
--- a/recipes/mesa/mesa-xlib_7.4.bb
+++ /dev/null
@@ -1,24 +0,0 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto"
-LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
-PR = "${INC_PR}.0"
-
-EXTRA_OECONF += "--with-driver=xlib"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-do_install_append () {
-    install -d ${D}/${bindir}
-    install -m 0755 ${S}/progs/xdemos/{glxdemo,glxgears,glxheads,glxinfo} ${D}/${bindir}
-}
-
-SRC_URI[archive.md5sum] = "7ecddb341a2691e0dfdb02f697109834"
-SRC_URI[archive.sha256sum] = "6e945389add4e5b41f2c403ced13c343767565f2eacde4b16de2d0f9f8a6aac4"
-SRC_URI[demos.md5sum] = "02816f10f30b1dc5e069e0f68c177c98"
-SRC_URI[demos.sha256sum] = "c3de74d62f925e32030adb3d0edcfb3c7a4129fc92c48181a389eeed8f14b897"
diff --git a/recipes/mesa/mesa_7.4.bb b/recipes/mesa/mesa_7.4.bb
deleted file mode 100644
index 43cde67..0000000
--- a/recipes/mesa/mesa_7.4.bb
+++ /dev/null
@@ -1,2 +0,0 @@
-# This is a dummy package so OE can use the poky mesa files
-require mesa-dri_${PV}.bb
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 6/9] mesa: move 7.8 release to latest minor 7.8.2
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (4 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in any distro/include config Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-25 12:19 ` [PATCH 7/9] mesa: move common definitions to include file, change SRC_URI to freedesktop for releases newer than 7.5 Martin Jansa
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 conf/distro/include/preferred-shr-versions.inc     |    1 -
 .../mesa/mesa-dri-7.8.1/fix-progs-makefile.patch   |   81 -
 recipes/mesa/mesa-dri-7.8.1/glamo.patch            | 2386 --------------------
 .../mesa/mesa-dri-7.8.2/fix-progs-makefile.patch   |   82 +
 recipes/mesa/mesa-dri-7.8.2/glamo.patch            | 2386 ++++++++++++++++++++
 recipes/mesa/mesa-dri-7.8/fix-progs-makefile.patch |   81 -
 recipes/mesa/mesa-dri-7.8/glamo.patch              | 2373 -------------------
 recipes/mesa/mesa-dri-glsl-native_7.8.2.bb         |   19 +
 recipes/mesa/mesa-dri-glsl-native_7.8.bb           |   20 -
 recipes/mesa/mesa-dri_7.8.1.bb                     |   43 -
 recipes/mesa/mesa-dri_7.8.2.bb                     |   43 +
 recipes/mesa/mesa-dri_7.8.bb                       |   41 -
 .../mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch  |   81 +
 .../mesa/mesa-xlib-7.8/fix-progs-makefile.patch    |   81 -
 recipes/mesa/mesa-xlib_7.8.2.bb                    |   20 +
 recipes/mesa/mesa-xlib_7.8.bb                      |   20 -
 recipes/mesa/mesa_7.8.2.bb                         |    8 +
 recipes/mesa/mesa_7.8.bb                           |    8 -
 18 files changed, 2639 insertions(+), 5135 deletions(-)
 delete mode 100644 recipes/mesa/mesa-dri-7.8.1/fix-progs-makefile.patch
 delete mode 100644 recipes/mesa/mesa-dri-7.8.1/glamo.patch
 create mode 100644 recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch
 create mode 100644 recipes/mesa/mesa-dri-7.8.2/glamo.patch
 delete mode 100644 recipes/mesa/mesa-dri-7.8/fix-progs-makefile.patch
 delete mode 100644 recipes/mesa/mesa-dri-7.8/glamo.patch
 create mode 100644 recipes/mesa/mesa-dri-glsl-native_7.8.2.bb
 delete mode 100644 recipes/mesa/mesa-dri-glsl-native_7.8.bb
 delete mode 100644 recipes/mesa/mesa-dri_7.8.1.bb
 create mode 100644 recipes/mesa/mesa-dri_7.8.2.bb
 delete mode 100644 recipes/mesa/mesa-dri_7.8.bb
 create mode 100644 recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch
 delete mode 100644 recipes/mesa/mesa-xlib-7.8/fix-progs-makefile.patch
 create mode 100644 recipes/mesa/mesa-xlib_7.8.2.bb
 delete mode 100644 recipes/mesa/mesa-xlib_7.8.bb
 create mode 100644 recipes/mesa/mesa_7.8.2.bb
 delete mode 100644 recipes/mesa/mesa_7.8.bb

diff --git a/conf/distro/include/preferred-shr-versions.inc b/conf/distro/include/preferred-shr-versions.inc
index 168989b..30ff61e 100644
--- a/conf/distro/include/preferred-shr-versions.inc
+++ b/conf/distro/include/preferred-shr-versions.inc
@@ -9,7 +9,6 @@ PREFERRED_VERSION_automake-native = "1.11.1"
 PREFERRED_VERSION_libmikmod = "3.2.0-beta2"
 PREFERRED_VERSION_mtd-utils-native = "1.2.0+git"
 PREFERRED_VERSION_strace = "4.5.15"
-PREFERRED_VERSION_mesa-dri     = "7.8.1"
 PREFERRED_VERSION_emacs-x11 = "23.1"
 
 # We need this for jamvm
diff --git a/recipes/mesa/mesa-dri-7.8.1/fix-progs-makefile.patch b/recipes/mesa/mesa-dri-7.8.1/fix-progs-makefile.patch
deleted file mode 100644
index 40e6a1b..0000000
--- a/recipes/mesa/mesa-dri-7.8.1/fix-progs-makefile.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
-From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Thu, 4 Mar 2010 14:16:27 +0100
-Subject: [PATCH] fix libs
-
----
- progs/demos/Makefile   |    2 +-
- progs/glsl/Makefile    |    2 +-
- progs/redbook/Makefile |    2 +-
- progs/samples/Makefile |    2 +-
- progs/xdemos/Makefile  |    2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index 5b1d2a0..121b862 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
- 	$(APP_LIB_DEPS)
- 
- PROGS = \
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 3b5a595..836c4ac 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -10,7 +10,7 @@ LIB_DEP = \
- 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
- 	-l$(GL_LIB) $(APP_LIB_DEPS)
- 
- # using : to avoid APP_CC pointing to CC loop
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index b41e488..95ed746 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = aaindex \
- 	aapoly \
-diff --git a/progs/samples/Makefile b/progs/samples/Makefile
-index 64fa47a..9f72c8b 100644
---- a/progs/samples/Makefile
-+++ b/progs/samples/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
-diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
-index f866a32..c0f4e06 100644
---- a/progs/xdemos/Makefile
-+++ b/progs/xdemos/Makefile
-@@ -11,7 +11,7 @@
- # Add X11 and pthread libs to satisfy GNU gold.
- APP_LIB_DEPS += -lX11 -lpthread
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = \
- 	corender \
--- 
-1.7.0
-
diff --git a/recipes/mesa/mesa-dri-7.8.1/glamo.patch b/recipes/mesa/mesa-dri-7.8.1/glamo.patch
deleted file mode 100644
index 52b4f3f..0000000
--- a/recipes/mesa/mesa-dri-7.8.1/glamo.patch
+++ /dev/null
@@ -1,2386 +0,0 @@
-diff --git a/configure.ac b/configure.ac
-index 61487c3..c4952bf 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -125,6 +125,9 @@ dnl Add flags for gcc and g++
- if test "x$GCC" = xyes; then
-     CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
- 
-+    # Work around GCC bug #39501
-+    CFLAGS="$CFLAGS -fno-finite-math-only"
-+
-     # Enable -fvisibility=hidden if using a gcc that supports it
-     save_CFLAGS="$CFLAGS"
-     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
-@@ -138,6 +141,9 @@ fi
- if test "x$GXX" = xyes; then
-     CXXFLAGS="$CXXFLAGS -Wall"
- 
-+    # Work around GCC bug #39501
-+    CXXFLAGS="$CXXFLAGS -fno-finite-math-only"
-+
-     # Work around aliasing bugs - developers should comment this out
-     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
- fi
-diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile
-new file mode 100644
-index 0000000..e77193d
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/Makefile
-@@ -0,0 +1,22 @@
-+# src/mesa/drivers/dri/glamo/Makefile
-+
-+TOP = ../../../../..
-+include $(TOP)/configs/current
-+
-+LIBNAME = glamo_dri.so
-+
-+DRIVER_SOURCES = \
-+	glamo_screen.c glamo_context.c glamo_state.c glamo_fbo.c glamo_tris.c \
-+	glamo_cmdq.c glamo_render.c
-+
-+C_SOURCES = \
-+	$(COMMON_SOURCES) \
-+	$(DRIVER_SOURCES)
-+
-+ASM_SOURCES =
-+
-+DRI_LIB_DEPS += -ldrm_glamo
-+
-+include ../Makefile.template
-+
-+symlinks:
-diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.c b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
-new file mode 100644
-index 0000000..1334f8e
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
-@@ -0,0 +1,110 @@
-+/*
-+ * Command queue submission via DRM
-+ *
-+ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <drm.h>
-+#include <glamo_drm.h>
-+#include <glamo_bo.h>
-+
-+#include "glamo_context.h"
-+#include "glamo_cmdq.h"
-+
-+
-+/* Submit the prepared command sequence to the kernel */
-+void glamoDRMDispatch(glamoContext *gCtx)
-+{
-+	drm_glamo_cmd_burst_t burst;
-+	int r;
-+
-+	burst.base = gCtx->cmd_burst_base;
-+	burst.data = gCtx->cmdq_drm;
-+	burst.bufsz = gCtx->cmdq_drm_used * 2;	/* -> bytes */
-+	burst.nobjs = gCtx->cmdq_obj_used;
-+	burst.objs = gCtx->cmdq_objs;
-+	burst.obj_pos = gCtx->cmdq_obj_pos;
-+
-+	r = drmCommandWrite(gCtx->drm_fd, DRM_GLAMO_CMDBURST,
-+	                    &burst, sizeof(burst));
-+	if ( r != 0 ) {
-+		fprintf(stderr, "DRM_GLAMO_CMDBURST failed\n");
-+	}
-+
-+	/* Reset counts to zero for the next sequence */
-+	gCtx->cmdq_obj_used = 0;
-+	gCtx->cmdq_drm_used = 0;
-+}
-+
-+
-+void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len)
-+{
-+	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
-+		fprintf(stderr, "Burst command too large\n");
-+		return;
-+	}
-+
-+	/* Record command */
-+	if ( len == 2 ) {
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff;
-+	} else if ( len == 4 ) {
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0x0000ffff;
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff0000;
-+	} else {
-+		fprintf(stderr, "Wrong command length!\n");
-+	}
-+}
-+
-+
-+void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo)
-+{
-+	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
-+		fprintf(stderr, "Burst command too large\n");
-+		return;
-+	}
-+
-+	/* Record object position */
-+	gCtx->cmdq_objs[gCtx->cmdq_obj_used] = bo->handle;
-+	/* -> bytes */
-+	gCtx->cmdq_obj_pos[gCtx->cmdq_obj_used] = gCtx->cmdq_drm_used * 2;
-+	gCtx->cmdq_obj_used++;
-+
-+	/* Record command */
-+	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
-+	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
-+}
-+
-+
-+void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base)
-+{
-+	gCtx->cmd_burst_base = base;
-+}
-+
-+
-+void glamoInitCmdqCache(glamoContext *gCtx)
-+{
-+	gCtx->cmdq_objs = malloc(1024);
-+	gCtx->cmdq_obj_pos = malloc(1024);
-+	gCtx->cmdq_obj_used = 0;
-+	gCtx->cmdq_drm_used = 0;
-+	gCtx->cmdq_drm_size = 4 * 1024;
-+	gCtx->cmdq_drm = malloc(gCtx->cmdq_drm_size);
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.h b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
-new file mode 100644
-index 0000000..7420d7b
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
-@@ -0,0 +1,33 @@
-+/*
-+ * Command queue submission via DRM
-+ *
-+ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+
-+#include <stdint.h>
-+#include <glamo_bo.h>
-+
-+#include "glamo_context.h"
-+
-+
-+extern void glamoDRMDispatch(glamoContext *gCtx);
-+extern void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo);
-+extern void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len);
-+extern void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base);
-+extern void glamoInitCmdqCache(glamoContext *gCtx);
-diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
-new file mode 100644
-index 0000000..527654f
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_context.c
-@@ -0,0 +1,360 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_context.c (c) 2003 Eric Anholt
-+ *              and radeon_common_context.c
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "dri_util.h"
-+#include "drirenderbuffer.h"
-+#include "utils.h"
-+
-+#include "swrast/swrast.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "drivers/common/driverfuncs.h"
-+#include "vbo/vbo.h"
-+#include "tnl/tnl.h"
-+#include "tnl/t_pipeline.h"
-+#include "main/state.h"
-+
-+#include "glamo_context.h"
-+#include "glamo_screen.h"
-+#include "glamo_state.h"
-+#include "glamo_fbo.h"
-+#include "glamo_tris.h"
-+#include "glamo_render.h"
-+#include "glamo_cmdq.h"
-+
-+#include <glamo_bo.h>
-+#include <glamo_bo_gem.h>
-+#include <glamo_drm.h>
-+
-+
-+#define DRIVER_DATE  "20090913"
-+
-+
-+static inline struct glamo_renderbuffer *glamo_get_renderbuffer(
-+                                                      struct gl_framebuffer *fb,
-+                                                      int att_index)
-+{
-+	if ( att_index >= 0 ) {
-+		struct glamo_renderbuffer *gr;
-+		gr = glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer);
-+		return gr;
-+	} else {
-+		return NULL;
-+	}
-+}
-+
-+
-+static const GLubyte *glamoGetString(GLcontext *ctx, GLenum name)
-+{
-+	static char buffer[128];
-+
-+	switch (name) {
-+	case GL_VENDOR:
-+		return (GLubyte *)"Thomas White";
-+	case GL_RENDERER: {
-+		driGetRendererString(buffer, "Glamo", DRIVER_DATE, 0);
-+		return (GLubyte *) buffer;
-+	}
-+	default:
-+		return 0;
-+	}
-+}
-+
-+
-+/* Called when Mesa needs to know the size of the framebuffer */
-+static void glamoBufferSize(GLframebuffer *buffer,
-+                            GLuint *width, GLuint *height)
-+{
-+	GET_CURRENT_CONTEXT(ctx);
-+	glamoContextPtr glamo = GLAMO_CONTEXT(ctx);
-+
-+	*width = glamo->driDrawable->w;
-+	*height = glamo->driDrawable->h;
-+}
-+
-+
-+GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
-+                             __DRIcontext *driContextPriv,
-+                             void *sharedContextPrivate)
-+{
-+	GLcontext *ctx, *shareCtx;
-+	__DRIscreen *sPriv = driContextPriv->driScreenPriv;
-+	glamoContextPtr context;
-+	glamoScreenPtr glamoScreen;
-+	struct dd_function_table functions;
-+
-+	context = (glamoContextPtr)CALLOC(sizeof(*context));
-+	if ( context == NULL ) return GL_FALSE;
-+
-+	_mesa_init_driver_functions(&functions);
-+
-+	/* Allocate the Mesa context */
-+	if ( sharedContextPrivate )
-+		shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
-+	else
-+		shareCtx = NULL;
-+	context->glCtx = _mesa_create_context(glVisual, shareCtx,
-+		                        &functions, (void *)context);
-+	if ( context->glCtx == NULL ) {
-+		FREE(context);
-+		return GL_FALSE;
-+	}
-+	driContextPriv->driverPrivate = context;
-+	ctx = context->glCtx;
-+
-+	glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
-+
-+	ctx->Driver.GetString = glamoGetString;
-+	ctx->Driver.GetBufferSize = glamoBufferSize;
-+
-+	context->driContext = driContextPriv;
-+	context->driScreen = sPriv;
-+	context->driDrawable = NULL;
-+	context->drm_fd = sPriv->fd;
-+
-+	/* Initialize the software rasterizer and helper modules. */
-+	_swrast_CreateContext(ctx);
-+	_vbo_CreateContext(ctx);
-+	_tnl_CreateContext(ctx);
-+	_swsetup_CreateContext(ctx);
-+
-+	/* Install our pipeline (see glamo_render.c) */
-+	_tnl_install_pipeline(ctx, glamo_pipeline);
-+
-+	_swrast_allow_pixel_fog(ctx, GL_TRUE);
-+	_swrast_allow_vertex_fog(ctx, GL_FALSE);
-+	_tnl_allow_pixel_fog(ctx, GL_TRUE);
-+	_tnl_allow_vertex_fog(ctx, GL_FALSE);
-+
-+	glamoInitCmdqCache(context);
-+	glamoInitStateFuncs(ctx);
-+	glamoInitTriFuncs(ctx);
-+
-+	return GL_TRUE;
-+}
-+
-+
-+void glamoDestroyContext(__DRIcontext *driContextPriv)
-+{
-+	glamoContextPtr context;
-+
-+	context = (glamoContextPtr)driContextPriv->driverPrivate;
-+	assert(context != NULL);
-+
-+	if ( context != NULL ) {
-+
-+		_swsetup_DestroyContext(context->glCtx);
-+		_tnl_DestroyContext(context->glCtx);
-+		_vbo_DestroyContext(context->glCtx);
-+		_swrast_DestroyContext(context->glCtx);
-+
-+		_mesa_destroy_context(context->glCtx);
-+
-+	}
-+
-+	FREE(context);
-+}
-+
-+
-+void glamo_update_renderbuffers(__DRIcontext *context,
-+                                __DRIdrawable *drawable)
-+{
-+	unsigned int attachments[10];
-+	__DRIbuffer *buffers;
-+	__DRIscreen *screen;
-+	int i, count;
-+	struct glamo_framebuffer *draw;
-+	glamoContextPtr glamo;
-+	struct glamo_bo *bo;
-+
-+	draw = drawable->driverPrivate;
-+	screen = context->driScreenPriv;
-+	glamo = (glamoContextPtr)context->driverPrivate;
-+	i = 0;
-+	if ( draw->color_rb[0] ) {
-+		attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-+	}
-+	if ( draw->color_rb[1] ) {
-+		attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-+	}
-+
-+	buffers = screen->dri2.loader->getBuffers(drawable,
-+	                                          &drawable->w,
-+	                                          &drawable->h,
-+	                                          attachments, i,
-+	                                          &count,
-+	                                          drawable->loaderPrivate);
-+	if ( buffers == NULL ) return;
-+
-+	/* Set one cliprect to cover the whole drawable */
-+	drawable->x = 0;
-+	drawable->y = 0;
-+	drawable->backX = 0;
-+	drawable->backY = 0;
-+	drawable->numClipRects = 1;
-+	drawable->pClipRects[0].x1 = 0;
-+	drawable->pClipRects[0].y1 = 0;
-+	drawable->pClipRects[0].x2 = drawable->w;
-+	drawable->pClipRects[0].y2 = drawable->h;
-+	drawable->numBackClipRects = 1;
-+	drawable->pBackClipRects[0].x1 = 0;
-+	drawable->pBackClipRects[0].y1 = 0;
-+	drawable->pBackClipRects[0].x2 = drawable->w;
-+	drawable->pBackClipRects[0].y2 = drawable->h;
-+
-+	/* For each attachment */
-+	for ( i=0; i<count; i++ ) {
-+
-+		struct glamo_renderbuffer *grb;
-+
-+		switch ( buffers[i].attachment ) {
-+		case __DRI_BUFFER_FRONT_LEFT:
-+			grb = draw->color_rb[0];
-+			break;
-+		case __DRI_BUFFER_BACK_LEFT:
-+			grb = draw->color_rb[1];
-+			break;
-+		case __DRI_BUFFER_DEPTH:
-+			grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH);
-+			break;
-+		case __DRI_BUFFER_STENCIL:
-+			grb = glamo_get_renderbuffer(&draw->base,
-+			                                        BUFFER_STENCIL);
-+			break;
-+		case __DRI_BUFFER_FAKE_FRONT_LEFT:
-+			grb = draw->color_rb[0];
-+			break;
-+		case __DRI_BUFFER_ACCUM:
-+		default:
-+			fprintf(stderr,
-+				"Unhandled buffer attach event,"
-+				" attachment type %d\n", buffers[i].attachment);
-+			return;
-+		}
-+
-+		if ( grb == NULL ) {
-+			/* Don't know how to handle this type of buffer */
-+			continue;
-+		}
-+
-+		if ( grb->bo ) {
-+			uint32_t name = glamo_gem_get_name(grb->bo);
-+			if ( name == buffers[i].name ) {
-+				/* Buffer already attached.  No action needed */
-+				continue;
-+			}
-+		}
-+
-+		grb->cpp = buffers[i].cpp;
-+		grb->pitch = buffers[i].pitch;
-+		grb->width = drawable->w;
-+		grb->height = drawable->h;
-+
-+		bo = glamo_bo_open(glamo->glamoScreen->bom, buffers[i].name,
-+		                   0, 0, GLAMO_GEM_DOMAIN_VRAM,
-+		                   buffers[i].flags);
-+		if ( bo == NULL ) {
-+			fprintf(stderr, "Failed to attach buffer %d\n",
-+				buffers[i].name);
-+		}
-+
-+		glamo_renderbuffer_set_bo(grb, bo);
-+		glamo_bo_unref(bo);
-+
-+	}
-+
-+	driUpdateFramebufferSize(glamo->glCtx, drawable);
-+}
-+
-+
-+GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
-+                           __DRIdrawable *driDrawPriv,
-+                           __DRIdrawable *driReadPriv)
-+{
-+	struct glamo_framebuffer *draw_fb;
-+	struct gl_framebuffer *read_fb;
-+	glamoContextPtr glamo;
-+
-+	if ( driContextPriv == NULL ) {
-+		_mesa_make_current(NULL, NULL, NULL);
-+		return GL_TRUE;
-+	}
-+
-+	/* The Glamo context we're switching to */
-+	glamo = (glamoContextPtr)driContextPriv->driverPrivate;
-+
-+	glamo->driDrawable = driDrawPriv;
-+
-+	/* These two will probably be the same */
-+	draw_fb = (struct glamo_framebuffer *)driDrawPriv->driverPrivate;
-+	read_fb = (struct gl_framebuffer *)driReadPriv->driverPrivate;
-+
-+	glamo_update_renderbuffers(driContextPriv, driDrawPriv);
-+	if (driDrawPriv != driReadPriv)
-+		glamo_update_renderbuffers(driContextPriv, driReadPriv);
-+
-+	_mesa_make_current(glamo->glCtx, &draw_fb->base, read_fb);
-+	_mesa_update_state(glamo->glCtx);
-+
-+	return GL_TRUE;
-+}
-+
-+
-+GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
-+{
-+	return GL_TRUE;
-+}
-+
-+
-+/* Convert IEEE754 32-bit float to Glamo's signed 24-bit float */
-+uint32_t float7s16(GLfloat in)
-+{
-+	uint32_t a, b;
-+	uint32_t sign, expo, mant;  /* Sign, exponent, significand */
-+
-+	a = *(uint32_t *)&in;
-+
-+	/* This is bad */
-+	if ( a & 0x40000000 ) {
-+		printf(stderr, "Warning: Exponent won't fit into 7 bits\n");
-+	}
-+
-+	/* This hopefully isn't a big problem */
-+	if ( a & 0x0000007f ) {
-+		printf(stderr, "Warning: Precision lost in FP conversion\n");
-+	}
-+
-+	/* Separate out the right bits */
-+	mant = a & 0x007fff80;  /* Bits 7-22 (bits 0-6 are lost) */
-+	expo = a & 0x3f800000;  /* Bits 23-29 (bit 30 is lost) */
-+	sign = a & 0x80000000;  /* Bit 31 */
-+
-+	/* Shift and recombine */
-+	b  = sign >> 8;  /* Fills bit 23 */
-+	b |= expo >> 7;  /* Fills bits 16-22 */
-+	b |= mant >> 7;  /* Fills bits 0-15 */
-+
-+	return b;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
-new file mode 100644
-index 0000000..ccce29c
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_context.h
-@@ -0,0 +1,106 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_context.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_CONTEXT_H
-+#define __GLAMO_CONTEXT_H
-+
-+
-+#include "dri_util.h"
-+#include "utils.h"
-+#include "tnl/t_vertex.h"
-+
-+#include "glamo_screen.h"
-+
-+
-+typedef struct glamo_context glamoContext;
-+typedef struct glamo_context *glamoContextPtr;
-+
-+struct glamo_context {
-+
-+	GLcontext *glCtx;                  /* Must be first in this structure */
-+
-+	int drm_fd;                        /* DRM fd */
-+
-+	__DRIcontext  *driContext;  /* DRI context */
-+	__DRIscreen   *driScreen;   /* DRI screen */
-+	__DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */
-+
-+	glamoScreenPtr glamoScreen;        /* Screen private DRI data */
-+
-+	driOptionCache optionCache;
-+
-+	uint16_t *cmdq_drm;                /* Command queue cache */
-+	uint16_t cmd_burst_base;
-+	int cmdq_drm_used;
-+	int cmdq_drm_size;
-+	int cmdq_obj_used;
-+	uint32_t *cmdq_objs;
-+	unsigned int *cmdq_obj_pos;
-+
-+	/* Information about the current primitive */
-+	struct {
-+		GLuint id;
-+		uint32_t primitive;	/* Current hardware primitive type */
-+		struct glamo_bo *vb_bo;
-+		uint8_t *vb;
-+		unsigned int start_offset; /* Byte offset of start */
-+		unsigned int current_offset; /* Byte offset of next vertex */
-+		unsigned int count;	/* Number of vertices */
-+	} prim;
-+
-+	/* Current vertex format and attributes */
-+	int vertex_size;
-+	struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
-+
-+	/* State */
-+	GLuint new_state;      /* State which must be updated */
-+	uint16_t col_clear;
-+
-+};
-+
-+#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
-+
-+#define TAG(x) glamo##x
-+#include "tnl_dd/t_dd_vertex.h"
-+#undef TAG
-+
-+extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
-+                                    __DRIcontext *driContextPriv,
-+                                    void *sharedContextPrivate);
-+extern void glamoDestroyContext(__DRIcontext *dcp);
-+extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
-+                                  __DRIdrawable *driDrawPriv,
-+                                  __DRIdrawable *driReadPriv);
-+extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
-+extern void glamo_update_renderbuffers(__DRIcontext *context,
-+                                       __DRIdrawable *drawable);
-+
-+#define GLAMO_PACKCOLOR565(r, g, b) \
-+	((((r) & 0xf8) << 8)        \
-+	| (((g) & 0xfc) << 3)       \
-+	| (((b) & 0xf8) >> 3))
-+
-+extern uint32_t float7s16(GLfloat in);
-+
-+#endif   /* __GLAMO_CONTEXT_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c
-new file mode 100644
-index 0000000..c866d21
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c
-@@ -0,0 +1,130 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on radeon_fbo.c (c) 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"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "main/imports.h"
-+#include "main/macros.h"
-+#include "main/mtypes.h"
-+#include "main/formats.h"
-+#include "main/fbobject.h"
-+#include "main/framebuffer.h"
-+#include "main/renderbuffer.h"
-+#include "main/context.h"
-+#include "dri_util.h"
-+
-+/* This comes from libdrm_glamo */
-+#include <glamo_bo.h>
-+
-+#include "glamo_fbo.h"
-+
-+
-+static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb)
-+{
-+   struct glamo_renderbuffer *grb = glamo_renderbuffer(rb);
-+
-+   ASSERT(grb);
-+
-+   if ( grb && grb->bo ) {
-+      glamo_bo_unref(grb->bo);
-+   }
-+   _mesa_free(grb);
-+}
-+
-+
-+static void *glamo_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb,
-+                               GLint x, GLint y)
-+{
-+   return NULL;   /* Can't be directly addressed */
-+}
-+
-+
-+/* Called for each hardware renderbuffer when a _window_ is resized.
-+ * Just update fields.
-+ * Not used for user-created renderbuffers!
-+ */
-+static GLboolean glamo_alloc_window_storage(GLcontext *ctx,
-+                                            struct gl_renderbuffer *rb,
-+                                            GLenum internalFormat,
-+                                            GLuint width, GLuint height)
-+{
-+   ASSERT(rb->Name == 0);
-+   rb->Width = width;
-+   rb->Height = height;
-+   rb->Format = internalFormat;
-+   return GL_TRUE;
-+}
-+
-+
-+/* Create a buffer, such as a colour or depth buffer */
-+struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
-+                                              __DRIdrawable *driDrawPriv)
-+{
-+   struct glamo_renderbuffer *grb;
-+
-+   grb = CALLOC_STRUCT(glamo_renderbuffer);
-+   if ( !grb ) return NULL;
-+
-+   _mesa_init_renderbuffer(&grb->base, 0);
-+   grb->base.ClassID = GLAMO_RB_CLASS;
-+
-+   switch (format) {
-+      case GL_RGB5:
-+         grb->base.Format = MESA_FORMAT_RGB565;
-+         grb->base._BaseFormat = GL_RGB;
-+
-+         grb->base.DataType = GL_UNSIGNED_BYTE;
-+         break;
-+      case GL_DEPTH_COMPONENT16:
-+         grb->base.DataType = GL_UNSIGNED_SHORT;
-+	 grb->base._BaseFormat = GL_DEPTH_COMPONENT;
-+         break;
-+      default:
-+         fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
-+         _mesa_delete_renderbuffer(&grb->base);
-+         return NULL;
-+   }
-+
-+   grb->dPriv = driDrawPriv;
-+   grb->base.InternalFormat = format;
-+
-+   grb->base.Delete = glamo_delete_renderbuffer;
-+   grb->base.AllocStorage = glamo_alloc_window_storage;
-+   grb->base.GetPointer = glamo_get_pointer;
-+
-+   return grb;
-+}
-+
-+
-+void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
-+                               struct glamo_bo *bo)
-+{
-+  struct glamo_bo *old;
-+  old = grb->bo;
-+  grb->bo = bo;
-+  glamo_bo_ref(bo);
-+  if ( old ) glamo_bo_unref(old);
-+}
-+
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h
-new file mode 100644
-index 0000000..48210dd
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h
-@@ -0,0 +1,77 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_FBO_H
-+#define __GLAMO_FBO_H
-+
-+
-+#include "main/mtypes.h"
-+#include "dri_util.h"
-+
-+
-+/* This is just a marker so we can tell a Glamo renderbuffer from a Mesa one */
-+#define GLAMO_RB_CLASS (0xdeadbeef)
-+
-+
-+struct glamo_renderbuffer
-+{
-+	struct gl_renderbuffer base;   /* Must be first */
-+	struct glamo_bo *bo;
-+	unsigned int cpp;
-+	unsigned int pitch;
-+	unsigned int width;
-+	unsigned int height;
-+
-+	__DRIdrawable *dPriv;
-+};
-+
-+
-+struct glamo_framebuffer
-+{
-+	struct gl_framebuffer base;
-+	struct glamo_renderbuffer *color_rb[2];
-+};
-+
-+
-+/* This is just a small wrapper function to return NULL if the gl_renderbuffer
-+ * is not a glamo_renderbuffer */
-+static inline struct glamo_renderbuffer
-+                                 *glamo_renderbuffer(struct gl_renderbuffer *rb)
-+{
-+	struct glamo_renderbuffer *grb = (struct glamo_renderbuffer *)rb;
-+	if ( grb && grb->base.ClassID == GLAMO_RB_CLASS )
-+		return grb;
-+	else
-+		return NULL;
-+}
-+
-+
-+extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
-+                                             __DRIdrawable *driDrawPriv);
-+
-+extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
-+                               struct glamo_bo *bo);
-+
-+#endif   /* __GLAMO_FBO_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_regs.h b/src/mesa/drivers/dri/glamo/glamo_regs.h
-new file mode 100644
-index 0000000..02b2294
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_regs.h
-@@ -0,0 +1,174 @@
-+#ifndef _GLAMO_REGS_H
-+#define _GLAMO_REGS_H
-+
-+/* Smedia Glamo 336x/337x driver
-+ *
-+ * (C) 2007 by OpenMoko, Inc.
-+ * Author: Harald Welte <laforge@openmoko.org>
-+ * All rights reserved.
-+ *
-+ * Modified for Glamo Mesa driver by Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+enum glamo_regster_offsets {
-+	GLAMO_REGOFS_GENERIC	= 0x0000,
-+	GLAMO_REGOFS_HOSTBUS	= 0x0200,
-+	GLAMO_REGOFS_MEMORY	= 0x0300,
-+	GLAMO_REGOFS_VIDCAP	= 0x0400,
-+	GLAMO_REGOFS_ISP	= 0x0500,
-+	GLAMO_REGOFS_JPEG	= 0x0800,
-+	GLAMO_REGOFS_MPEG	= 0x0c00,
-+	GLAMO_REGOFS_LCD	= 0x1100,
-+	GLAMO_REGOFS_MMC	= 0x1400,
-+	GLAMO_REGOFS_MPROC0	= 0x1500,
-+	GLAMO_REGOFS_MPROC1	= 0x1580,
-+	GLAMO_REGOFS_CMDQUEUE	= 0x1600,
-+	GLAMO_REGOFS_RISC	= 0x1680,
-+	GLAMO_REGOFS_2D		= 0x1700,
-+	GLAMO_REGOFS_3D		= 0x1b00,
-+};
-+
-+
-+#define REG_MPEG(x)           (GLAMO_REGOFS_MPEG+(x))
-+
-+enum glamo_register_mpeg {
-+      //
-+      GLAMO_REG_MPEG_DC_ADDRL         = REG_MPEG(0x3c),
-+      GLAMO_REG_MPEG_DC_ADDRH         = REG_MPEG(0x3e),
-+      GLAMO_REG_MPEG_AC_ADDRL         = REG_MPEG(0x40),
-+      GLAMO_REG_MPEG_AC_ADDRH         = REG_MPEG(0x42),
-+      //
-+      GLAMO_REG_MPEG_SAFE_1           = REG_MPEG(0x60),
-+      GLAMO_REG_MPEG_SAFE_2           = REG_MPEG(0x62),
-+      GLAMO_REG_MPEG_SAFE_3           = REG_MPEG(0x64),
-+      //
-+      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRL = REG_MPEG(0x6e),
-+      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRH = REG_MPEG(0x70),
-+      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRL = REG_MPEG(0x72),
-+      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRH = REG_MPEG(0x74),
-+      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRL = REG_MPEG(0x76),
-+      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRH = REG_MPEG(0x78),
-+      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRL = REG_MPEG(0x7a),
-+      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRH = REG_MPEG(0x7c),
-+      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRL = REG_MPEG(0x7e),
-+      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRH = REG_MPEG(0x80),
-+      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRL = REG_MPEG(0x82),
-+      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRH = REG_MPEG(0x84),
-+      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRL = REG_MPEG(0x86),
-+      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRH = REG_MPEG(0x88),
-+      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRL = REG_MPEG(0x8a),
-+      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRH = REG_MPEG(0x8c),
-+      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRL = REG_MPEG(0x8e),
-+      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRH = REG_MPEG(0x90),
-+      GLAMO_REG_MPEG_DEC_WIDTH        = REG_MPEG(0x92),
-+      GLAMO_REG_MPEG_DEC_HEIGHT       = REG_MPEG(0x94),
-+      GLAMO_REG_MPEG_SPECIAL          = REG_MPEG(0x96),
-+      GLAMO_REG_MPEG_DEC_IN_ADDRL     = REG_MPEG(0x98),
-+      GLAMO_REG_MPEG_DEC_IN_ADDRH     = REG_MPEG(0x9a),
-+      //
-+      GLAMO_REG_MPEG_DEBLK_THRESHOLD  = REG_MPEG(0xc0),
-+      //
-+      GLAMO_REG_MPEG_DEC_STATUS       = REG_MPEG(0xc8),
-+      GLAMO_REG_MPEG_DEC_RB0          = REG_MPEG(0xca),
-+      GLAMO_REG_MPEG_DEC_RB1          = REG_MPEG(0xcc),
-+};
-+
-+
-+#define REG_2D(x)		(GLAMO_REGOFS_2D+(x))
-+
-+enum glamo_register_2d {
-+	GLAMO_REG_2D_SRC_ADDRL		= REG_2D(0x00),
-+	GLAMO_REG_2D_SRC_ADDRH		= REG_2D(0x02),
-+	GLAMO_REG_2D_SRC_PITCH		= REG_2D(0x04),
-+	GLAMO_REG_2D_SRC_X		= REG_2D(0x06),
-+	GLAMO_REG_2D_SRC_Y		= REG_2D(0x08),
-+	GLAMO_REG_2D_DST_X		= REG_2D(0x0a),
-+	GLAMO_REG_2D_DST_Y		= REG_2D(0x0c),
-+	GLAMO_REG_2D_DST_ADDRL		= REG_2D(0x0e),
-+	GLAMO_REG_2D_DST_ADDRH		= REG_2D(0x10),
-+	GLAMO_REG_2D_DST_PITCH		= REG_2D(0x12),
-+	GLAMO_REG_2D_DST_HEIGHT		= REG_2D(0x14),
-+	GLAMO_REG_2D_RECT_WIDTH		= REG_2D(0x16),
-+	GLAMO_REG_2D_RECT_HEIGHT	= REG_2D(0x18),
-+	GLAMO_REG_2D_PAT_ADDRL		= REG_2D(0x1a),
-+	GLAMO_REG_2D_PAT_ADDRH		= REG_2D(0x1c),
-+	GLAMO_REG_2D_PAT_FG		= REG_2D(0x1e),
-+	GLAMO_REG_2D_PAT_BG		= REG_2D(0x20),
-+	GLAMO_REG_2D_SRC_FG		= REG_2D(0x22),
-+	GLAMO_REG_2D_SRC_BG		= REG_2D(0x24),
-+	GLAMO_REG_2D_MASK1		= REG_2D(0x26),
-+	GLAMO_REG_2D_MASK2		= REG_2D(0x28),
-+	GLAMO_REG_2D_MASK3		= REG_2D(0x2a),
-+	GLAMO_REG_2D_MASK4		= REG_2D(0x2c),
-+	GLAMO_REG_2D_ROT_X		= REG_2D(0x2e),
-+	GLAMO_REG_2D_ROT_Y		= REG_2D(0x30),
-+	GLAMO_REG_2D_LEFT_CLIP		= REG_2D(0x32),
-+	GLAMO_REG_2D_TOP_CLIP		= REG_2D(0x34),
-+	GLAMO_REG_2D_RIGHT_CLIP		= REG_2D(0x36),
-+	GLAMO_REG_2D_BOTTOM_CLIP	= REG_2D(0x38),
-+	GLAMO_REG_2D_COMMAND1		= REG_2D(0x3A),
-+	GLAMO_REG_2D_COMMAND2		= REG_2D(0x3C),
-+	GLAMO_REG_2D_COMMAND3		= REG_2D(0x3E),
-+	GLAMO_REG_2D_SAFE		= REG_2D(0x40),
-+	GLAMO_REG_2D_STATUS		= REG_2D(0x42),
-+	GLAMO_REG_2D_ID1		= REG_2D(0x44),
-+	GLAMO_REG_2D_ID2		= REG_2D(0x46),
-+	GLAMO_REG_2D_ID3		= REG_2D(0x48),
-+};
-+
-+
-+/* No offset this time */
-+#define REG_3D(x)		(x)
-+
-+enum glamo_register_3d
-+{
-+	/* Fire the engine */
-+	G3D_FIRE			= REG_3D(0x2058),
-+
-+	/* Streams of vertex/colour/normal/texcoord data */
-+	G3D_ACTIVE_STREAMS		= REG_3D(0x1f00),
-+	G3D_LAST_STREAM__VCOLFMT	= REG_3D(0x2030),
-+	G3D_STREAM_MODE_0		= REG_3D(0x1f10),
-+	G3D_STREAM_BASE_0		= REG_3D(0x1f14),
-+	G3D_STREAM_MODE_1		= REG_3D(0x1f18),
-+	G3D_STREAM_BASE_1		= REG_3D(0x1f1c),
-+	G3D_STREAM_MODE_2		= REG_3D(0x1f20),
-+	G3D_STREAM_BASE_2		= REG_3D(0x1f24),
-+	G3D_STREAM_MODE_3		= REG_3D(0x1f28),
-+	G3D_STREAM_BASE_3		= REG_3D(0x1f2c),
-+	G3D_STREAM_MODE_4		= REG_3D(0x1f30),
-+	G3D_STREAM_BASE_4		= REG_3D(0x1f34),
-+	G3D_STREAM_MODE_5		= REG_3D(0x1f38),
-+	G3D_STREAM_BASE_5		= REG_3D(0x1f3c),
-+	G3D_STREAM_MODE_6		= REG_3D(0x1f40),
-+	G3D_STREAM_BASE_6		= REG_3D(0x1f44),
-+	G3D_STREAM_MODE_7		= REG_3D(0x1f48),
-+	G3D_STREAM_BASE_7		= REG_3D(0x1f4c),
-+
-+	/* Modelview*projection matrix */
-+	G3D_MATRIX_MVP			= REG_3D(0x26a0), /* .. 0x27df */
-+
-+	/* Modelview matrix */
-+	G3D_MATRIX_MV			= REG_3D(0x26e0), /* .. 0x270f */
-+
-+	/* Inverse MVP, 3x3 only */
-+	G3D_MATRIX_IMVP			= REG_3D(0x2710), /* .. 0x2733 */
-+
-+};
-+
-+#endif /* _GLAMO_REGS_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c
-new file mode 100644
-index 0000000..fd52418
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_render.c
-@@ -0,0 +1,230 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Based on intel_render.c, to which the following notice applies:
-+ *
-+ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS 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.
-+ *
-+ */
-+
-+
-+/*
-+ * Render unclipped vertex buffers by emitting vertices directly to
-+ * dma buffers.  Use strip/fan hardware acceleration where possible.
-+ *
-+ */
-+#include "main/glheader.h"
-+#include "main/context.h"
-+#include "main/macros.h"
-+#include "main/imports.h"
-+#include "main/mtypes.h"
-+#include "main/enums.h"
-+
-+#include "tnl/t_context.h"
-+#include "tnl/t_vertex.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "glamo_context.h"
-+#include "glamo_tris.h"
-+#include "glamo_regs.h"
-+
-+/*
-+ * Render unclipped vertex buffers by emitting vertices directly to
-+ * VRAM buffers.  Use strip/fan hardware primitives where possible.
-+ * Try to simulate missing primitives with indexed vertices.
-+ */
-+#define HAVE_POINTS      1
-+#define HAVE_LINES       1
-+#define HAVE_LINE_STRIPS 0
-+#define HAVE_TRIANGLES   1
-+#define HAVE_TRI_STRIPS  0
-+#define HAVE_TRI_STRIP_1 0
-+#define HAVE_TRI_FANS    0
-+#define HAVE_POLYGONS    0
-+#define HAVE_QUADS       0
-+#define HAVE_QUAD_STRIPS 0
-+#define HAVE_ELTS        0
-+
-+
-+static void glamoFlushPrim(struct glamo_context *gCtx)
-+{
-+	printf("glamoFlushPrim: %i vertices, %i %i\n", gCtx->prim.count,
-+	gCtx->prim.start_offset, gCtx->prim.current_offset);
-+
-+	if ( gCtx->prim.vb_bo == NULL ) return;
-+
-+	/* Upload to hardware */
-+	glamo_bo_subdata(gCtx->prim.vb_bo, 0, gCtx->prim.current_offset,
-+	                 gCtx->prim.vb);
-+
-+	/* Dispatch to the hardware */
-+	glamoDRMStartBurst(gCtx, G3D_STREAM_MODE_0);
-+	glamoDRMAddData(gCtx, 0x000f0300, 4);
-+	glamoDRMAddBO(gCtx, gCtx->prim.vb_bo);
-+	glamoDRMDispatch(gCtx);
-+
-+	/* Please use a new BO for the next buffer */
-+	gCtx->prim.vb_bo = NULL;
-+
-+	/* Continue from new start */
-+	gCtx->prim.start_offset = gCtx->prim.current_offset;
-+}
-+
-+
-+static inline GLuint glamoGetVBMax(struct glamo_context *gCtx)
-+{
-+	return GLAMO_VB_SIZE / gCtx->vertex_size;
-+}
-+
-+
-+static inline GLuint glamoGetCurrentMax(struct glamo_context *gCtx)
-+{
-+	/* How many more vertices can be accommodated?
-+	 * Each vertex takes up 4x 32-bit fixed point values */
-+	return (GLAMO_VB_SIZE - gCtx->prim.current_offset) / gCtx->vertex_size;
-+}
-+
-+
-+#define LOCAL_VARS \
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+#define INIT(prim)
-+
-+#define FLUSH() glamoFlushPrim(gCtx)
-+
-+#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx)
-+#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx)
-+
-+#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr)
-+
-+#define EMIT_VERTS(ctx, j, nr, buf) \
-+	_tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
-+
-+#define TAG(x) glamo_##x
-+#include "tnl_dd/t_dd_dmatmp.h"
-+
-+
-+/**********************************************************************/
-+/*                          Render pipeline stage                     */
-+/**********************************************************************/
-+
-+static void glamoFireEngine(struct glamo_context *gCtx)
-+{
-+	glamoDRMStartBurst(gCtx, G3D_FIRE);
-+	glamoDRMAddData(gCtx, 0, 2);  /* Fire! */
-+	glamoDRMDispatch(gCtx);
-+}
-+
-+
-+static GLboolean glamoRunRender(GLcontext *ctx,
-+                                struct tnl_pipeline_stage *stage)
-+{
-+	TNLcontext *tnl = TNL_CONTEXT(ctx);
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	struct vertex_buffer *VB = &tnl->vb;
-+	GLuint i;
-+
-+	printf("glamoRunRender\n");
-+
-+	/* Don't handle clipping */
-+	if ( !glamo_validate_render(ctx, VB) ) {
-+		return GL_TRUE; /* Failed */
-+	}
-+
-+	/* Validate GPU state */
-+	if ( gCtx->new_state ) {
-+		if ( !glamoValidateState(ctx, gCtx->new_state) ) {
-+			printf("Couldn't validate state...\n");
-+		}
-+	} /* else nothing to update */
-+
-+	tnl->clipspace.new_inputs |= VERT_BIT_POS;
-+
-+	tnl->Driver.Render.Start(ctx);
-+
-+	for ( i=0; i<VB->PrimitiveCount; i++ ) {
-+
-+		GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
-+		GLuint start = VB->Primitive[i].start;
-+		GLuint length = VB->Primitive[i].count;
-+
-+		if (!length) continue;
-+
-+		glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start,
-+                                                     start + length, prim);
-+
-+	}
-+
-+	tnl->Driver.Render.Finish(ctx);
-+
-+	glamoFireEngine(gCtx);
-+
-+	return GL_FALSE;  /* Ok */
-+}
-+
-+
-+static const struct tnl_pipeline_stage _glamo_render_stage = {
-+	"glamo render",
-+	NULL,
-+	NULL,
-+	NULL,
-+	NULL,
-+	glamoRunRender
-+};
-+
-+
-+const struct tnl_pipeline_stage *glamo_pipeline[] = {
-+	&_tnl_vertex_transform_stage,
-+	&_tnl_vertex_cull_stage,
-+	&_tnl_normal_transform_stage,
-+	&_tnl_lighting_stage,
-+	&_tnl_fog_coordinate_stage,
-+	&_tnl_texgen_stage,
-+	&_tnl_texture_transform_stage,
-+	&_tnl_point_attenuation_stage,
-+	&_tnl_vertex_program_stage,
-+	&_glamo_render_stage,        /* ADD: unclipped rastersetup-to-dma */
-+	&_tnl_render_stage,
-+	0,
-+};
-diff --git a/src/mesa/drivers/dri/glamo/glamo_render.h b/src/mesa/drivers/dri/glamo/glamo_render.h
-new file mode 100644
-index 0000000..99c36a8
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_render.h
-@@ -0,0 +1,31 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_RENDER_H
-+#define __GLAMO_RENDER_H
-+
-+#include "main/mtypes.h"
-+
-+extern const struct tnl_pipeline_stage *glamo_pipeline[];
-+
-+#endif   /* __GLAMO_RENDER_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
-new file mode 100644
-index 0000000..39148f3
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
-@@ -0,0 +1,250 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_screen.c (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "dri_util.h"
-+#include "utils.h"
-+#include "xmlconfig.h"
-+#include "GL/internal/dri_interface.h"
-+#include "main/framebuffer.h"
-+#include "main/renderbuffer.h"
-+
-+#include "glamo_screen.h"
-+#include "glamo_context.h"
-+#include "glamo_fbo.h"
-+
-+/* This comes from libdrm_glamo */
-+#include <glamo_bo_gem.h>
-+
-+
-+static int glamoInitDriver(__DRIscreen *psp)
-+{
-+   return 0;
-+}
-+
-+
-+static glamoScreenPtr glamoCreateScreen(__DRIscreen *sPriv)
-+{
-+   glamoScreenPtr glamoScreen;
-+
-+   /* Allocate the private area */
-+   glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen));
-+   if ( glamoScreen == NULL )
-+      return NULL;
-+
-+   glamoScreen->driScreen = sPriv;
-+
-+   /* This is our link to the kernel's memory manager, via libdrm */
-+   glamoScreen->bom = glamo_bo_manager_gem_ctor(sPriv->fd);
-+
-+   return glamoScreen;
-+}
-+
-+
-+static void glamoDestroyScreen(__DRIscreen *sPriv)
-+{
-+   glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private;
-+
-+   if ( glamoScreen == NULL )
-+      return;
-+
-+   FREE(glamoScreen);
-+   sPriv->private = NULL;
-+}
-+
-+
-+static const __DRIconfig **glamoInitScreen(__DRIscreen *sPriv)
-+{
-+   __DRIconfig **configs;
-+   uint8_t depth_bits_array[2];
-+   uint8_t stencil_bits_array[2];
-+   uint8_t msaa_samples_array[1];
-+   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
-+
-+   /* Driver initialisation */
-+   if ( glamoInitDriver(sPriv) ) {
-+      return NULL;
-+   }
-+
-+   /* Screen-specific initialisation */
-+   sPriv->private = glamoCreateScreen(sPriv);
-+   if ( !sPriv->private ) {
-+      glamoDestroyScreen(sPriv);
-+      return NULL;
-+   }
-+
-+   depth_bits_array[0] = 0;
-+   stencil_bits_array[0] = 0;
-+   depth_bits_array[1] = 16;
-+   stencil_bits_array[1] = 0;
-+   msaa_samples_array[0] = 0;
-+
-+   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-+                           depth_bits_array, stencil_bits_array, 2,
-+                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
-+
-+   if ( configs == NULL ) {
-+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
-+      return NULL;
-+   }
-+
-+   return (const __DRIconfig **)configs;
-+}
-+
-+
-+static const __DRIconfig **glamoInitScreen2(__DRIscreen *sPriv)
-+{
-+   __DRIconfig **configs;
-+   uint8_t depth_bits_array[2];
-+   uint8_t stencil_bits_array[2];
-+   uint8_t msaa_samples_array[1];
-+   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
-+
-+   /* Driver initialisation */
-+   if ( glamoInitDriver(sPriv) ) {
-+      return NULL;
-+   }
-+
-+   /* Screen-specific initialisation */
-+   sPriv->private = glamoCreateScreen(sPriv);
-+   if ( !sPriv->private ) {
-+      glamoDestroyScreen(sPriv);
-+      return NULL;
-+   }
-+
-+   depth_bits_array[0] = 0;
-+   stencil_bits_array[0] = 0;
-+   depth_bits_array[1] = 16;
-+   stencil_bits_array[1] = 0;
-+   msaa_samples_array[0] = 0;
-+
-+   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-+                           depth_bits_array, stencil_bits_array, 2,
-+                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
-+
-+   if ( configs == NULL ) {
-+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
-+      return NULL;
-+   }
-+
-+   return (const __DRIconfig **)configs;
-+}
-+
-+
-+/* Allocate buffers for a context.  This is where the fun starts... */
-+static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
-+                                   __DRIdrawable *driDrawPriv,
-+                                   const __GLcontextModes *mesaVis,
-+                                   GLboolean isPixmap)
-+{
-+   struct glamo_framebuffer *gfb;
-+   GLenum rgbFormat;
-+
-+   if ( isPixmap ) return GL_FALSE; /* not implemented */
-+
-+   gfb = CALLOC_STRUCT(glamo_framebuffer);
-+   if ( !gfb ) return GL_FALSE;
-+
-+   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
-+
-+   /* we only support this one format at the moment */
-+   rgbFormat = GL_RGB5;
-+
-+   /* Front color renderbuffer */
-+   gfb->color_rb[0] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
-+   _mesa_add_renderbuffer(&gfb->base, BUFFER_FRONT_LEFT,
-+                          &gfb->color_rb[0]->base);
-+
-+   /* Back color renderbuffer, if requested */
-+   if ( mesaVis->doubleBufferMode ) {
-+      gfb->color_rb[1] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
-+      _mesa_add_renderbuffer(&gfb->base, BUFFER_BACK_LEFT,
-+                             &gfb->color_rb[1]->base);
-+   }
-+
-+   if ( mesaVis->depthBits == 16 ) {
-+      struct glamo_renderbuffer *depth;
-+      depth = glamo_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
-+      _mesa_add_renderbuffer(&gfb->base, BUFFER_DEPTH, &depth->base);
-+   }
-+
-+   /* Add software renderbuffers for the things we can't support in hardware */
-+   _mesa_add_soft_renderbuffers(&gfb->base,
-+      GL_FALSE,  /* color */
-+      GL_FALSE,  /* depth */
-+      mesaVis->stencilBits > 0,   /* stencil, if required */
-+      mesaVis->accumRedBits > 0,  /* accum, if required */
-+      GL_FALSE,  /* alpha */
-+      GL_FALSE   /* aux */
-+   );
-+   driDrawPriv->driverPrivate = (void *)gfb;
-+
-+   return (driDrawPriv->driverPrivate != NULL);
-+}
-+
-+
-+static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
-+{
-+}
-+
-+
-+static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
-+{
-+   printf("glamoSwapBuffers\n"); fflush(stdout);
-+}
-+
-+
-+/*
-+ *  Mesa entry points
-+ *
-+ *  See src/mesa/drivers/dri/common/dri_util.h for information about these
-+ */
-+const struct __DriverAPIRec driDriverAPI = {
-+   .InitScreen      = glamoInitScreen,
-+   .DestroyScreen   = glamoDestroyScreen,
-+   .CreateContext   = glamoCreateContext,
-+   .DestroyContext  = glamoDestroyContext,
-+   .CreateBuffer    = glamoCreateBuffer,
-+   .DestroyBuffer   = glamoDestroyBuffer,
-+   .SwapBuffers     = glamoSwapBuffers,
-+   .MakeCurrent     = glamoMakeCurrent,
-+   .UnbindContext   = glamoUnbindContext,
-+   .GetSwapInfo     = NULL,   /* Not used */
-+   .WaitForMSC      = NULL,
-+   .WaitForSBC      = NULL,
-+   .SwapBuffersMSC  = NULL,
-+   .CopySubBuffer   = NULL,
-+   .GetDrawableMSC  = NULL,   /* Not used */
-+   .InitScreen2     = glamoInitScreen2,    /* For DRI2 */
-+};
-+
-+/* This is the table of extensions that the loader will dlsym() for. */
-+PUBLIC const __DRIextension *__driDriverExtensions[] = {
-+    &driCoreExtension.base,
-+    &driLegacyExtension.base,
-+    &driDRI2Extension.base,
-+    NULL
-+};
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h
-new file mode 100644
-index 0000000..3f2eb5f
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.h
-@@ -0,0 +1,44 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_screen.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_SCREEN_H
-+#define __GLAMO_SCREEN_H
-+
-+#include "xmlconfig.h"
-+#include "dri_util.h"
-+
-+#include <glamo_bo_gem.h>
-+
-+typedef struct {
-+
-+   __DRIscreen *driScreen;
-+   driOptionCache optionCache;
-+
-+   struct glamo_bo_manager *bom;
-+
-+} glamoScreenRec, *glamoScreenPtr;
-+
-+#endif   /* __GLAMO_SCREEN_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c
-new file mode 100644
-index 0000000..4046c24
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_state.c
-@@ -0,0 +1,304 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009-2010 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_state.c (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Also partially based on intel_fbo.c, to which the following notice applies:
-+ *
-+ * Copyright 2006 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "main/context.h"
-+#include "main/framebuffer.h"
-+#include "main/api_arrayelt.h"
-+#include "swrast/swrast.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "tnl/tnl.h"
-+
-+#include "glamo_fbo.h"
-+#include "glamo_state.h"
-+#include "glamo_context.h"
-+#include "glamo_cmdq.h"
-+#include "glamo_regs.h"
-+
-+
-+static void glamoResizeBuffers(GLcontext *ctx, struct gl_framebuffer *fb,
-+                               GLuint width, GLuint height)
-+{
-+	struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb;
-+	int i;
-+
-+	_mesa_resize_framebuffer(ctx, fb, width, height);
-+
-+	fb->Initialized = GL_TRUE; /* XXX remove someday */
-+
-+	if (fb->Name != 0) {
-+		return;
-+	}
-+
-+	/* Make sure all window system renderbuffers are up to date */
-+	for (i = 0; i < 2; i++) {
-+		struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base;
-+
-+		/* only resize if size is changing */
-+		if (rb && (rb->Width != width || rb->Height != height)) {
-+			rb->AllocStorage(ctx, rb, rb->InternalFormat,
-+		                         width, height);
-+		}
-+	}
-+}
-+
-+
-+static void glamoClear(GLcontext *ctx, GLbitfield mask)
-+{
-+	glamoContext *gCtx;
-+	struct gl_framebuffer *fb;
-+	int i;
-+
-+	gCtx = GLAMO_CONTEXT(ctx);
-+	fb = ctx->DrawBuffer;
-+
-+	printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0],
-+	       ctx->Color.ClearColor[1], ctx->Color.ClearColor[2],
-+	       ctx->Color.ClearColor[3]); fflush(stdout);
-+
-+	for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
-+
-+		struct glamo_renderbuffer *grb;
-+
-+		grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]);
-+
-+		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_DST_X);
-+		glamoDRMAddData(gCtx, fb->_Xmin, 2);           /* dest X */
-+		glamoDRMAddData(gCtx, fb->_Ymin, 2);           /* dest Y */
-+		glamoDRMAddBO(gCtx, grb->bo);                  /* dest L/H */
-+		glamoDRMAddData(gCtx, grb->pitch & 0x7ff, 2);  /* dest pitch */
-+		glamoDRMAddData(gCtx, grb->height, 2);         /* dest height */
-+		glamoDRMAddData(gCtx, fb->_Xmax-fb->_Xmin, 2); /* width */
-+		glamoDRMAddData(gCtx, fb->_Ymax-fb->_Ymin, 2); /* height */
-+		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt L */
-+		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt H */
-+		glamoDRMAddData(gCtx, gCtx->col_clear, 2);     /* FG colour */
-+		glamoDRMDispatch(gCtx);
-+
-+		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_COMMAND1);
-+		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 1 */
-+		glamoDRMAddData(gCtx, 0xf0 << 8, 2); /* Cmd param 2 */
-+		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 3 */
-+		glamoDRMDispatch(gCtx);
-+
-+	}
-+}
-+
-+
-+static void glamoClearColor(GLcontext *ctx, const GLfloat color[4])
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	GLubyte col_byte[4];
-+
-+	printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2],
-+	       color[3]); fflush(stdout);
-+
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]);
-+
-+	gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1],
-+	                                     col_byte[2]);
-+}
-+
-+
-+static void glamoShadeModel(GLcontext *ctx, GLenum mode)
-+{
-+	printf("glamoShadeModel\n"); fflush(stdout);
-+}
-+
-+
-+static void glamoViewport(GLcontext *ctx, GLint x, GLint y,
-+                          GLsizei width, GLsizei height )
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	__DRIcontext *driContext = gCtx->driContext;
-+	void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
-+			 GLsizei w, GLsizei h);
-+
-+	if ( !driContext->driScreenPriv->dri2.enabled ) return;
-+
-+	/* TODO: Flush before fiddling with fake front buffer */
-+
-+	if ( ctx->DrawBuffer->Name == 0 ) {
-+
-+		glamo_update_renderbuffers(driContext,
-+		                           driContext->driDrawablePriv);
-+		if ( driContext->driDrawablePriv
-+		                              != driContext->driReadablePriv ) {
-+			glamo_update_renderbuffers(driContext,
-+				                   driContext->driReadablePriv);
-+		}
-+
-+	}
-+
-+	old_viewport = ctx->Driver.Viewport;
-+	ctx->Driver.Viewport = NULL;
-+	gCtx->driDrawable = driContext->driDrawablePriv;
-+	ctx->Driver.Viewport = old_viewport;
-+}
-+
-+
-+static void glamoUploadMatrix(struct glamo_context *gCtx, uint16_t mreg,
-+                              GLfloat *matrix)
-+{
-+	int i;
-+	char *type;
-+
-+	switch ( mreg ) {
-+	case G3D_MATRIX_MVP :
-+		type = "MVP"; break;
-+	case G3D_MATRIX_MV :
-+		type = "MV"; break;
-+	case G3D_MATRIX_IMVP :
-+		type = "inverse MVP"; break;
-+	default :
-+		type = "unknown"; break;
-+	}
-+	printf("Uploading %s matrix...\n", type);
-+
-+	glamoDRMStartBurst(gCtx, mreg);
-+	if ( mreg != G3D_MATRIX_IMVP ) {
-+		for ( i=0; i<16; i++ ) {
-+			glamoDRMAddData(gCtx, float7s16(matrix[i]), 4);
-+		}
-+	} else {
-+		/* Normal matrix needs special treatment */
-+		for ( i=0; i<3; i++ ) {
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i]), 4);
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i+1]), 4);
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i+2]), 4);
-+		}
-+	}
-+	glamoDRMDispatch(gCtx);
-+}
-+
-+
-+GLboolean glamoValidateState(GLcontext *ctx, GLuint new_state)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	if ( new_state & (_NEW_MODELVIEW|_NEW_PROJECTION) ) {
-+
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_MVP,
-+		                  ctx->_ModelProjectMatrix.m);
-+
-+		/* FIXME: The following two aren't needed unless lighting
-+		 * is in use... */
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_MV,
-+		                  ctx->ModelviewMatrixStack.Top->m);
-+		_math_matrix_alloc_inv(&(ctx->_ModelProjectMatrix));
-+		_math_matrix_analyse(&(ctx->_ModelProjectMatrix));
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_IMVP,
-+		                  ctx->_ModelProjectMatrix.inv);
-+	}
-+
-+	gCtx->new_state = 0;
-+	return GL_TRUE;
-+}
-+
-+
-+static void glamoUpdateState(GLcontext *ctx, GLbitfield new_state)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	printf("glamoUpdateState\n");
-+
-+	_swrast_InvalidateState(ctx, new_state);
-+	_swsetup_InvalidateState(ctx, new_state);
-+	_vbo_InvalidateState(ctx, new_state);
-+	_tnl_InvalidateState(ctx, new_state);
-+	_ae_invalidate_state(ctx, new_state);
-+
-+	/* Make a note that some state has changed,
-+	 * so that it can be sent to the GPU later. */
-+	gCtx->new_state |= new_state;
-+}
-+
-+
-+static void glamoFlush(GLcontext *ctx)
-+{
-+	printf("glamoFlush\n");
-+}
-+
-+
-+void glamoInitStateFuncs(GLcontext *ctx)
-+{
-+	ctx->Driver.UpdateState       = glamoUpdateState;
-+	ctx->Driver.Clear             = glamoClear;
-+	ctx->Driver.ClearColor        = glamoClearColor;
-+	ctx->Driver.ClearDepth        = NULL;
-+	ctx->Driver.ClearStencil      = NULL;
-+	ctx->Driver.AlphaFunc         = NULL;
-+	ctx->Driver.BlendFuncSeparate = NULL;
-+	ctx->Driver.ColorMask         = NULL;
-+	ctx->Driver.CullFace          = NULL;
-+	ctx->Driver.DepthMask         = NULL;
-+	ctx->Driver.DepthFunc         = NULL;
-+	ctx->Driver.DepthRange        = NULL;
-+	ctx->Driver.DrawBuffer        = NULL;
-+	ctx->Driver.Enable            = NULL;
-+	ctx->Driver.FrontFace         = NULL;
-+	ctx->Driver.Fogfv             = NULL;
-+	ctx->Driver.Hint              = NULL;
-+	ctx->Driver.Lightfv           = NULL;
-+	ctx->Driver.LogicOpcode       = NULL;
-+	ctx->Driver.PolygonMode       = NULL;
-+	ctx->Driver.PolygonStipple    = NULL;
-+	ctx->Driver.ReadBuffer        = NULL;
-+	ctx->Driver.RenderMode        = NULL;
-+	ctx->Driver.Scissor           = NULL;
-+	ctx->Driver.ShadeModel        = glamoShadeModel;
-+	ctx->Driver.LightModelfv      = NULL;
-+	ctx->Driver.Viewport          = glamoViewport;
-+	ctx->Driver.ResizeBuffers     = glamoResizeBuffers;
-+	ctx->Driver.Flush             = glamoFlush;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_state.h b/src/mesa/drivers/dri/glamo/glamo_state.h
-new file mode 100644
-index 0000000..98f0b97
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_state.h
-@@ -0,0 +1,34 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_state.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_STATE_H
-+#define __GLAMO_STATE_H
-+
-+#include "main/context.h"
-+
-+extern void glamoInitStateFuncs(GLcontext *ctx);
-+
-+#endif   /* __GLAMO_STATE_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.c b/src/mesa/drivers/dri/glamo/glamo_tris.c
-new file mode 100644
-index 0000000..6c6b5a6
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_tris.c
-@@ -0,0 +1,310 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Based on intel_tris.c, to which the following notice applies:
-+ *
-+ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ *
-+ */
-+
-+
-+#include <glamo_bo.h>
-+#include <glamo_bo_gem.h>
-+#include <glamo_drm.h>
-+
-+#include "main/mtypes.h"
-+#include "swrast/swrast.h"
-+#include "tnl/t_context.h"
-+#include "tnl/t_vertex.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "glamo_tris.h"
-+#include "glamo_context.h"
-+
-+
-+static void glamoRunPipeline(GLcontext *ctx)
-+{
-+	printf("glamoRunPipeline\n");
-+
-+	/* TODO: Emit state */
-+
-+	_tnl_run_pipeline(ctx);
-+}
-+
-+
-+static void glamoRenderStart(GLcontext *ctx)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	/* Decide which attributes will be used */
-+	gCtx->vertex_attrs[0].attrib = _TNL_ATTRIB_POS;
-+	gCtx->vertex_attrs[0].format = EMIT_4F;
-+
-+	gCtx->vertex_size = _tnl_install_attrs(ctx, gCtx->vertex_attrs, 1,
-+	                                       NULL, 0);
-+}
-+
-+
-+static void glamoRenderFinish(GLcontext *ctx)
-+{
-+	printf("glamoRenderFinish\n");
-+}
-+
-+
-+static void glamoPrimitiveNotify(GLcontext *ctx, GLenum prim)
-+{
-+	printf("glamoPrimitiveNotify\n");
-+}
-+
-+
-+uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, unsigned int count)
-+{
-+	uint32_t *addr;
-+
-+	printf("glamoGetPrimSpace\n");
-+
-+	/* Check for space in the existing VB */
-+	if (gCtx->prim.vb_bo == NULL || (gCtx->prim.current_offset +
-+	                           count * gCtx->vertex_size) > GLAMO_VB_SIZE) {
-+
-+		/* Not enough space, or no VB existing. Start a new one... */
-+		if (gCtx->prim.vb == NULL) {
-+			printf("Allocated %i bytes\n", GLAMO_VB_SIZE);
-+			gCtx->prim.vb = malloc(GLAMO_VB_SIZE);
-+		}
-+		gCtx->prim.vb_bo = glamo_bo_open(gCtx->glamoScreen->bom, 0,
-+		                                 GLAMO_VB_SIZE, 4,
-+		                                 GLAMO_GEM_DOMAIN_VRAM, 0);
-+		gCtx->prim.start_offset = 0;
-+		gCtx->prim.current_offset = 0;
-+	}
-+
-+	addr = (uint32_t *)(gCtx->prim.vb + gCtx->prim.current_offset);
-+	gCtx->prim.current_offset += gCtx->vertex_size * count;
-+	gCtx->prim.count += count;
-+
-+	return addr;
-+}
-+
-+
-+#define COPY_DWORDS( j, vb, vertsize, v )	\
-+do {						\
-+   for ( j = 0 ; j < vertsize ; j++ ) {		\
-+      vb[j] = ((GLuint *)v)[j];			\
-+   }						\
-+   vb += vertsize;				\
-+} while (0)
-+
-+
-+static void glamo_draw_triangle(struct glamo_context *gCtx,
-+                                glamoVertexPtr v0, glamoVertexPtr v1,
-+                                glamoVertexPtr v2)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 3);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v2);
-+}
-+
-+
-+static void glamo_draw_line(struct glamo_context *gCtx,
-+                            glamoVertexPtr v0, glamoVertexPtr v1)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
-+}
-+
-+
-+static void glamo_draw_point(struct glamo_context *gCtx, glamoVertexPtr v0)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+}
-+
-+
-+#define TRI( a, b, c )                          \
-+do {                                            \
-+        glamo_draw_triangle(gCtx, a, b, c  );   \
-+} while (0)
-+
-+
-+#define QUAD( a, b, c, d )                      \
-+printf("Drawing a quad\n");                     \
-+do {                                            \
-+        glamo_draw_triangle(gCtx, a, b, d);     \
-+        glamo_draw_triangle(gCtx, b, c, d);     \
-+} while (0)
-+
-+
-+#define LINE(v0, v1)                            \
-+do {                                            \
-+        glamo_draw_line(gCtx, v0, v1);          \
-+} while (0)
-+
-+
-+#define POINT(v0)                               \
-+do {                                            \
-+        glamo_draw_point(gCtx, v0);             \
-+} while (0)
-+
-+
-+#define IND (0)
-+#define TAG(x) x
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+
-+static void init_rast_tab()
-+{
-+	init();
-+	init_offset();
-+	init_twoside();
-+	init_twoside_offset();
-+	init_unfilled();
-+	init_offset_unfilled();
-+	init_twoside_unfilled();
-+	init_twoside_offset_unfilled();
-+	init_fallback();
-+	init_offset_fallback();
-+	init_twoside_fallback();
-+	init_twoside_offset_fallback();
-+	init_unfilled_fallback();
-+	init_offset_unfilled_fallback();
-+	init_twoside_unfilled_fallback();
-+	init_twoside_offset_unfilled_fallback();
-+}
-+
-+
-+void glamoInitTriFuncs(GLcontext *ctx)
-+{
-+	TNLcontext *tnl = TNL_CONTEXT(ctx);
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	static int firsttime = 1;
-+
-+	if (firsttime) {
-+		init_rast_tab();
-+		firsttime = 0;
-+	}
-+
-+	gCtx->prim.start_offset = 0;
-+	gCtx->prim.current_offset = 0;
-+	gCtx->prim.vb_bo = NULL;
-+	gCtx->prim.vb = NULL;
-+	gCtx->prim.count = 0;
-+
-+	tnl->Driver.RunPipeline = glamoRunPipeline;
-+	tnl->Driver.Render.Start = glamoRenderStart;
-+	tnl->Driver.Render.Finish = glamoRenderFinish;
-+	tnl->Driver.Render.PrimitiveNotify = glamoPrimitiveNotify;
-+	tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
-+	tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
-+	tnl->Driver.Render.CopyPV = _tnl_copy_pv;
-+	tnl->Driver.Render.Interp = _tnl_interp;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.h b/src/mesa/drivers/dri/glamo/glamo_tris.h
-new file mode 100644
-index 0000000..ba8f997
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_tris.h
-@@ -0,0 +1,38 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_TRIS_H
-+#define __GLAMO_TRIS_H
-+
-+#include "main/mtypes.h"
-+
-+#include "glamo_context.h"
-+
-+/* Amount of space reserved for vertex submission */
-+#define GLAMO_VB_SIZE (32*1024)
-+
-+extern void glamoInitTriFuncs(GLcontext *ctx);
-+extern uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx,
-+                                   unsigned int count);
-+
-+#endif   /* __GLAMO_TRIS_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
-index 39148f3..8244ec3 100644
---- a/src/mesa/drivers/dri/glamo/glamo_screen.c
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
-@@ -166,7 +166,7 @@ static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
-    gfb = CALLOC_STRUCT(glamo_framebuffer);
-    if ( !gfb ) return GL_FALSE;
- 
--   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
-+   _mesa_initialize_window_framebuffer(&gfb->base, mesaVis);
- 
-    /* we only support this one format at the moment */
-    rgbFormat = GL_RGB5;
diff --git a/recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch b/recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch
new file mode 100644
index 0000000..f05d4b0
--- /dev/null
+++ b/recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch
@@ -0,0 +1,82 @@
+From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
+From: Martin Jansa <Martin.Jansa@gmail.com>
+Date: Thu, 4 Mar 2010 14:16:27 +0100
+Subject: [PATCH] fix libs
+
+---
+ progs/demos/Makefile   |    2 +-
+ progs/glsl/Makefile    |    2 +-
+ progs/redbook/Makefile |    2 +-
+ progs/samples/Makefile |    2 +-
+ progs/xdemos/Makefile  |    2 +-
+ 5 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/progs/demos/Makefile b/progs/demos/Makefile
+index 5b1d2a0..121b862 100644
+--- a/progs/demos/Makefile
++++ b/progs/demos/Makefile
+@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
+ 	$(APP_LIB_DEPS)
+ 
+ PROGS = \
+diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
+index 3b5a595..836c4ac 100644
+--- a/progs/glsl/Makefile
++++ b/progs/glsl/Makefile
+@@ -10,7 +10,7 @@ LIB_DEP = \
+ 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
+ 	-l$(GL_LIB) $(APP_LIB_DEPS)
+ 
+ # using : to avoid APP_CC pointing to CC loop
+diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
+index b41e488..95ed746 100644
+--- a/progs/redbook/Makefile
++++ b/progs/redbook/Makefile
+@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
+ 
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = aaindex \
+ 	aapoly \
+diff --git a/progs/samples/Makefile b/progs/samples/Makefile
+index 64fa47a..9f72c8b 100644
+--- a/progs/samples/Makefile
++++ b/progs/samples/Makefile
+@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
+ 
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
+ 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
+diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
+index f866a32..c0f4e06 100644
+--- a/progs/xdemos/Makefile
++++ b/progs/xdemos/Makefile
+@@ -11,7 +11,7 @@
+ # Add X11 and pthread libs to satisfy GNU gold.
+ APP_LIB_DEPS += -lX11 -lpthread
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+
+ 
+ PROGS = \
+ 	corender \
+-- 
+1.7.0
+
diff --git a/recipes/mesa/mesa-dri-7.8.2/glamo.patch b/recipes/mesa/mesa-dri-7.8.2/glamo.patch
new file mode 100644
index 0000000..52b4f3f
--- /dev/null
+++ b/recipes/mesa/mesa-dri-7.8.2/glamo.patch
@@ -0,0 +1,2386 @@
+diff --git a/configure.ac b/configure.ac
+index 61487c3..c4952bf 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -125,6 +125,9 @@ dnl Add flags for gcc and g++
+ if test "x$GCC" = xyes; then
+     CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
+ 
++    # Work around GCC bug #39501
++    CFLAGS="$CFLAGS -fno-finite-math-only"
++
+     # Enable -fvisibility=hidden if using a gcc that supports it
+     save_CFLAGS="$CFLAGS"
+     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
+@@ -138,6 +141,9 @@ fi
+ if test "x$GXX" = xyes; then
+     CXXFLAGS="$CXXFLAGS -Wall"
+ 
++    # Work around GCC bug #39501
++    CXXFLAGS="$CXXFLAGS -fno-finite-math-only"
++
+     # Work around aliasing bugs - developers should comment this out
+     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+ fi
+diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile
+new file mode 100644
+index 0000000..e77193d
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/Makefile
+@@ -0,0 +1,22 @@
++# src/mesa/drivers/dri/glamo/Makefile
++
++TOP = ../../../../..
++include $(TOP)/configs/current
++
++LIBNAME = glamo_dri.so
++
++DRIVER_SOURCES = \
++	glamo_screen.c glamo_context.c glamo_state.c glamo_fbo.c glamo_tris.c \
++	glamo_cmdq.c glamo_render.c
++
++C_SOURCES = \
++	$(COMMON_SOURCES) \
++	$(DRIVER_SOURCES)
++
++ASM_SOURCES =
++
++DRI_LIB_DEPS += -ldrm_glamo
++
++include ../Makefile.template
++
++symlinks:
+diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.c b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
+new file mode 100644
+index 0000000..1334f8e
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
+@@ -0,0 +1,110 @@
++/*
++ * Command queue submission via DRM
++ *
++ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++
++#include <stdint.h>
++#include <stdlib.h>
++#include <drm.h>
++#include <glamo_drm.h>
++#include <glamo_bo.h>
++
++#include "glamo_context.h"
++#include "glamo_cmdq.h"
++
++
++/* Submit the prepared command sequence to the kernel */
++void glamoDRMDispatch(glamoContext *gCtx)
++{
++	drm_glamo_cmd_burst_t burst;
++	int r;
++
++	burst.base = gCtx->cmd_burst_base;
++	burst.data = gCtx->cmdq_drm;
++	burst.bufsz = gCtx->cmdq_drm_used * 2;	/* -> bytes */
++	burst.nobjs = gCtx->cmdq_obj_used;
++	burst.objs = gCtx->cmdq_objs;
++	burst.obj_pos = gCtx->cmdq_obj_pos;
++
++	r = drmCommandWrite(gCtx->drm_fd, DRM_GLAMO_CMDBURST,
++	                    &burst, sizeof(burst));
++	if ( r != 0 ) {
++		fprintf(stderr, "DRM_GLAMO_CMDBURST failed\n");
++	}
++
++	/* Reset counts to zero for the next sequence */
++	gCtx->cmdq_obj_used = 0;
++	gCtx->cmdq_drm_used = 0;
++}
++
++
++void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len)
++{
++	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
++		fprintf(stderr, "Burst command too large\n");
++		return;
++	}
++
++	/* Record command */
++	if ( len == 2 ) {
++		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff;
++	} else if ( len == 4 ) {
++		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0x0000ffff;
++		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff0000;
++	} else {
++		fprintf(stderr, "Wrong command length!\n");
++	}
++}
++
++
++void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo)
++{
++	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
++		fprintf(stderr, "Burst command too large\n");
++		return;
++	}
++
++	/* Record object position */
++	gCtx->cmdq_objs[gCtx->cmdq_obj_used] = bo->handle;
++	/* -> bytes */
++	gCtx->cmdq_obj_pos[gCtx->cmdq_obj_used] = gCtx->cmdq_drm_used * 2;
++	gCtx->cmdq_obj_used++;
++
++	/* Record command */
++	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
++	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
++}
++
++
++void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base)
++{
++	gCtx->cmd_burst_base = base;
++}
++
++
++void glamoInitCmdqCache(glamoContext *gCtx)
++{
++	gCtx->cmdq_objs = malloc(1024);
++	gCtx->cmdq_obj_pos = malloc(1024);
++	gCtx->cmdq_obj_used = 0;
++	gCtx->cmdq_drm_used = 0;
++	gCtx->cmdq_drm_size = 4 * 1024;
++	gCtx->cmdq_drm = malloc(gCtx->cmdq_drm_size);
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.h b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
+new file mode 100644
+index 0000000..7420d7b
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
+@@ -0,0 +1,33 @@
++/*
++ * Command queue submission via DRM
++ *
++ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++
++#include <stdint.h>
++#include <glamo_bo.h>
++
++#include "glamo_context.h"
++
++
++extern void glamoDRMDispatch(glamoContext *gCtx);
++extern void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo);
++extern void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len);
++extern void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base);
++extern void glamoInitCmdqCache(glamoContext *gCtx);
+diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
+new file mode 100644
+index 0000000..527654f
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_context.c
+@@ -0,0 +1,360 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_context.c (c) 2003 Eric Anholt
++ *              and radeon_common_context.c
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "dri_util.h"
++#include "drirenderbuffer.h"
++#include "utils.h"
++
++#include "swrast/swrast.h"
++#include "swrast_setup/swrast_setup.h"
++#include "drivers/common/driverfuncs.h"
++#include "vbo/vbo.h"
++#include "tnl/tnl.h"
++#include "tnl/t_pipeline.h"
++#include "main/state.h"
++
++#include "glamo_context.h"
++#include "glamo_screen.h"
++#include "glamo_state.h"
++#include "glamo_fbo.h"
++#include "glamo_tris.h"
++#include "glamo_render.h"
++#include "glamo_cmdq.h"
++
++#include <glamo_bo.h>
++#include <glamo_bo_gem.h>
++#include <glamo_drm.h>
++
++
++#define DRIVER_DATE  "20090913"
++
++
++static inline struct glamo_renderbuffer *glamo_get_renderbuffer(
++                                                      struct gl_framebuffer *fb,
++                                                      int att_index)
++{
++	if ( att_index >= 0 ) {
++		struct glamo_renderbuffer *gr;
++		gr = glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer);
++		return gr;
++	} else {
++		return NULL;
++	}
++}
++
++
++static const GLubyte *glamoGetString(GLcontext *ctx, GLenum name)
++{
++	static char buffer[128];
++
++	switch (name) {
++	case GL_VENDOR:
++		return (GLubyte *)"Thomas White";
++	case GL_RENDERER: {
++		driGetRendererString(buffer, "Glamo", DRIVER_DATE, 0);
++		return (GLubyte *) buffer;
++	}
++	default:
++		return 0;
++	}
++}
++
++
++/* Called when Mesa needs to know the size of the framebuffer */
++static void glamoBufferSize(GLframebuffer *buffer,
++                            GLuint *width, GLuint *height)
++{
++	GET_CURRENT_CONTEXT(ctx);
++	glamoContextPtr glamo = GLAMO_CONTEXT(ctx);
++
++	*width = glamo->driDrawable->w;
++	*height = glamo->driDrawable->h;
++}
++
++
++GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
++                             __DRIcontext *driContextPriv,
++                             void *sharedContextPrivate)
++{
++	GLcontext *ctx, *shareCtx;
++	__DRIscreen *sPriv = driContextPriv->driScreenPriv;
++	glamoContextPtr context;
++	glamoScreenPtr glamoScreen;
++	struct dd_function_table functions;
++
++	context = (glamoContextPtr)CALLOC(sizeof(*context));
++	if ( context == NULL ) return GL_FALSE;
++
++	_mesa_init_driver_functions(&functions);
++
++	/* Allocate the Mesa context */
++	if ( sharedContextPrivate )
++		shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
++	else
++		shareCtx = NULL;
++	context->glCtx = _mesa_create_context(glVisual, shareCtx,
++		                        &functions, (void *)context);
++	if ( context->glCtx == NULL ) {
++		FREE(context);
++		return GL_FALSE;
++	}
++	driContextPriv->driverPrivate = context;
++	ctx = context->glCtx;
++
++	glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
++
++	ctx->Driver.GetString = glamoGetString;
++	ctx->Driver.GetBufferSize = glamoBufferSize;
++
++	context->driContext = driContextPriv;
++	context->driScreen = sPriv;
++	context->driDrawable = NULL;
++	context->drm_fd = sPriv->fd;
++
++	/* Initialize the software rasterizer and helper modules. */
++	_swrast_CreateContext(ctx);
++	_vbo_CreateContext(ctx);
++	_tnl_CreateContext(ctx);
++	_swsetup_CreateContext(ctx);
++
++	/* Install our pipeline (see glamo_render.c) */
++	_tnl_install_pipeline(ctx, glamo_pipeline);
++
++	_swrast_allow_pixel_fog(ctx, GL_TRUE);
++	_swrast_allow_vertex_fog(ctx, GL_FALSE);
++	_tnl_allow_pixel_fog(ctx, GL_TRUE);
++	_tnl_allow_vertex_fog(ctx, GL_FALSE);
++
++	glamoInitCmdqCache(context);
++	glamoInitStateFuncs(ctx);
++	glamoInitTriFuncs(ctx);
++
++	return GL_TRUE;
++}
++
++
++void glamoDestroyContext(__DRIcontext *driContextPriv)
++{
++	glamoContextPtr context;
++
++	context = (glamoContextPtr)driContextPriv->driverPrivate;
++	assert(context != NULL);
++
++	if ( context != NULL ) {
++
++		_swsetup_DestroyContext(context->glCtx);
++		_tnl_DestroyContext(context->glCtx);
++		_vbo_DestroyContext(context->glCtx);
++		_swrast_DestroyContext(context->glCtx);
++
++		_mesa_destroy_context(context->glCtx);
++
++	}
++
++	FREE(context);
++}
++
++
++void glamo_update_renderbuffers(__DRIcontext *context,
++                                __DRIdrawable *drawable)
++{
++	unsigned int attachments[10];
++	__DRIbuffer *buffers;
++	__DRIscreen *screen;
++	int i, count;
++	struct glamo_framebuffer *draw;
++	glamoContextPtr glamo;
++	struct glamo_bo *bo;
++
++	draw = drawable->driverPrivate;
++	screen = context->driScreenPriv;
++	glamo = (glamoContextPtr)context->driverPrivate;
++	i = 0;
++	if ( draw->color_rb[0] ) {
++		attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
++	}
++	if ( draw->color_rb[1] ) {
++		attachments[i++] = __DRI_BUFFER_BACK_LEFT;
++	}
++
++	buffers = screen->dri2.loader->getBuffers(drawable,
++	                                          &drawable->w,
++	                                          &drawable->h,
++	                                          attachments, i,
++	                                          &count,
++	                                          drawable->loaderPrivate);
++	if ( buffers == NULL ) return;
++
++	/* Set one cliprect to cover the whole drawable */
++	drawable->x = 0;
++	drawable->y = 0;
++	drawable->backX = 0;
++	drawable->backY = 0;
++	drawable->numClipRects = 1;
++	drawable->pClipRects[0].x1 = 0;
++	drawable->pClipRects[0].y1 = 0;
++	drawable->pClipRects[0].x2 = drawable->w;
++	drawable->pClipRects[0].y2 = drawable->h;
++	drawable->numBackClipRects = 1;
++	drawable->pBackClipRects[0].x1 = 0;
++	drawable->pBackClipRects[0].y1 = 0;
++	drawable->pBackClipRects[0].x2 = drawable->w;
++	drawable->pBackClipRects[0].y2 = drawable->h;
++
++	/* For each attachment */
++	for ( i=0; i<count; i++ ) {
++
++		struct glamo_renderbuffer *grb;
++
++		switch ( buffers[i].attachment ) {
++		case __DRI_BUFFER_FRONT_LEFT:
++			grb = draw->color_rb[0];
++			break;
++		case __DRI_BUFFER_BACK_LEFT:
++			grb = draw->color_rb[1];
++			break;
++		case __DRI_BUFFER_DEPTH:
++			grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH);
++			break;
++		case __DRI_BUFFER_STENCIL:
++			grb = glamo_get_renderbuffer(&draw->base,
++			                                        BUFFER_STENCIL);
++			break;
++		case __DRI_BUFFER_FAKE_FRONT_LEFT:
++			grb = draw->color_rb[0];
++			break;
++		case __DRI_BUFFER_ACCUM:
++		default:
++			fprintf(stderr,
++				"Unhandled buffer attach event,"
++				" attachment type %d\n", buffers[i].attachment);
++			return;
++		}
++
++		if ( grb == NULL ) {
++			/* Don't know how to handle this type of buffer */
++			continue;
++		}
++
++		if ( grb->bo ) {
++			uint32_t name = glamo_gem_get_name(grb->bo);
++			if ( name == buffers[i].name ) {
++				/* Buffer already attached.  No action needed */
++				continue;
++			}
++		}
++
++		grb->cpp = buffers[i].cpp;
++		grb->pitch = buffers[i].pitch;
++		grb->width = drawable->w;
++		grb->height = drawable->h;
++
++		bo = glamo_bo_open(glamo->glamoScreen->bom, buffers[i].name,
++		                   0, 0, GLAMO_GEM_DOMAIN_VRAM,
++		                   buffers[i].flags);
++		if ( bo == NULL ) {
++			fprintf(stderr, "Failed to attach buffer %d\n",
++				buffers[i].name);
++		}
++
++		glamo_renderbuffer_set_bo(grb, bo);
++		glamo_bo_unref(bo);
++
++	}
++
++	driUpdateFramebufferSize(glamo->glCtx, drawable);
++}
++
++
++GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
++                           __DRIdrawable *driDrawPriv,
++                           __DRIdrawable *driReadPriv)
++{
++	struct glamo_framebuffer *draw_fb;
++	struct gl_framebuffer *read_fb;
++	glamoContextPtr glamo;
++
++	if ( driContextPriv == NULL ) {
++		_mesa_make_current(NULL, NULL, NULL);
++		return GL_TRUE;
++	}
++
++	/* The Glamo context we're switching to */
++	glamo = (glamoContextPtr)driContextPriv->driverPrivate;
++
++	glamo->driDrawable = driDrawPriv;
++
++	/* These two will probably be the same */
++	draw_fb = (struct glamo_framebuffer *)driDrawPriv->driverPrivate;
++	read_fb = (struct gl_framebuffer *)driReadPriv->driverPrivate;
++
++	glamo_update_renderbuffers(driContextPriv, driDrawPriv);
++	if (driDrawPriv != driReadPriv)
++		glamo_update_renderbuffers(driContextPriv, driReadPriv);
++
++	_mesa_make_current(glamo->glCtx, &draw_fb->base, read_fb);
++	_mesa_update_state(glamo->glCtx);
++
++	return GL_TRUE;
++}
++
++
++GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
++{
++	return GL_TRUE;
++}
++
++
++/* Convert IEEE754 32-bit float to Glamo's signed 24-bit float */
++uint32_t float7s16(GLfloat in)
++{
++	uint32_t a, b;
++	uint32_t sign, expo, mant;  /* Sign, exponent, significand */
++
++	a = *(uint32_t *)&in;
++
++	/* This is bad */
++	if ( a & 0x40000000 ) {
++		printf(stderr, "Warning: Exponent won't fit into 7 bits\n");
++	}
++
++	/* This hopefully isn't a big problem */
++	if ( a & 0x0000007f ) {
++		printf(stderr, "Warning: Precision lost in FP conversion\n");
++	}
++
++	/* Separate out the right bits */
++	mant = a & 0x007fff80;  /* Bits 7-22 (bits 0-6 are lost) */
++	expo = a & 0x3f800000;  /* Bits 23-29 (bit 30 is lost) */
++	sign = a & 0x80000000;  /* Bit 31 */
++
++	/* Shift and recombine */
++	b  = sign >> 8;  /* Fills bit 23 */
++	b |= expo >> 7;  /* Fills bits 16-22 */
++	b |= mant >> 7;  /* Fills bits 0-15 */
++
++	return b;
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
+new file mode 100644
+index 0000000..ccce29c
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_context.h
+@@ -0,0 +1,106 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_context.h (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_CONTEXT_H
++#define __GLAMO_CONTEXT_H
++
++
++#include "dri_util.h"
++#include "utils.h"
++#include "tnl/t_vertex.h"
++
++#include "glamo_screen.h"
++
++
++typedef struct glamo_context glamoContext;
++typedef struct glamo_context *glamoContextPtr;
++
++struct glamo_context {
++
++	GLcontext *glCtx;                  /* Must be first in this structure */
++
++	int drm_fd;                        /* DRM fd */
++
++	__DRIcontext  *driContext;  /* DRI context */
++	__DRIscreen   *driScreen;   /* DRI screen */
++	__DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */
++
++	glamoScreenPtr glamoScreen;        /* Screen private DRI data */
++
++	driOptionCache optionCache;
++
++	uint16_t *cmdq_drm;                /* Command queue cache */
++	uint16_t cmd_burst_base;
++	int cmdq_drm_used;
++	int cmdq_drm_size;
++	int cmdq_obj_used;
++	uint32_t *cmdq_objs;
++	unsigned int *cmdq_obj_pos;
++
++	/* Information about the current primitive */
++	struct {
++		GLuint id;
++		uint32_t primitive;	/* Current hardware primitive type */
++		struct glamo_bo *vb_bo;
++		uint8_t *vb;
++		unsigned int start_offset; /* Byte offset of start */
++		unsigned int current_offset; /* Byte offset of next vertex */
++		unsigned int count;	/* Number of vertices */
++	} prim;
++
++	/* Current vertex format and attributes */
++	int vertex_size;
++	struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
++
++	/* State */
++	GLuint new_state;      /* State which must be updated */
++	uint16_t col_clear;
++
++};
++
++#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
++
++#define TAG(x) glamo##x
++#include "tnl_dd/t_dd_vertex.h"
++#undef TAG
++
++extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
++                                    __DRIcontext *driContextPriv,
++                                    void *sharedContextPrivate);
++extern void glamoDestroyContext(__DRIcontext *dcp);
++extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
++                                  __DRIdrawable *driDrawPriv,
++                                  __DRIdrawable *driReadPriv);
++extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
++extern void glamo_update_renderbuffers(__DRIcontext *context,
++                                       __DRIdrawable *drawable);
++
++#define GLAMO_PACKCOLOR565(r, g, b) \
++	((((r) & 0xf8) << 8)        \
++	| (((g) & 0xfc) << 3)       \
++	| (((b) & 0xf8) >> 3))
++
++extern uint32_t float7s16(GLfloat in);
++
++#endif   /* __GLAMO_CONTEXT_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c
+new file mode 100644
+index 0000000..c866d21
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c
+@@ -0,0 +1,130 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on radeon_fbo.c (c) 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"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "main/imports.h"
++#include "main/macros.h"
++#include "main/mtypes.h"
++#include "main/formats.h"
++#include "main/fbobject.h"
++#include "main/framebuffer.h"
++#include "main/renderbuffer.h"
++#include "main/context.h"
++#include "dri_util.h"
++
++/* This comes from libdrm_glamo */
++#include <glamo_bo.h>
++
++#include "glamo_fbo.h"
++
++
++static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb)
++{
++   struct glamo_renderbuffer *grb = glamo_renderbuffer(rb);
++
++   ASSERT(grb);
++
++   if ( grb && grb->bo ) {
++      glamo_bo_unref(grb->bo);
++   }
++   _mesa_free(grb);
++}
++
++
++static void *glamo_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb,
++                               GLint x, GLint y)
++{
++   return NULL;   /* Can't be directly addressed */
++}
++
++
++/* Called for each hardware renderbuffer when a _window_ is resized.
++ * Just update fields.
++ * Not used for user-created renderbuffers!
++ */
++static GLboolean glamo_alloc_window_storage(GLcontext *ctx,
++                                            struct gl_renderbuffer *rb,
++                                            GLenum internalFormat,
++                                            GLuint width, GLuint height)
++{
++   ASSERT(rb->Name == 0);
++   rb->Width = width;
++   rb->Height = height;
++   rb->Format = internalFormat;
++   return GL_TRUE;
++}
++
++
++/* Create a buffer, such as a colour or depth buffer */
++struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
++                                              __DRIdrawable *driDrawPriv)
++{
++   struct glamo_renderbuffer *grb;
++
++   grb = CALLOC_STRUCT(glamo_renderbuffer);
++   if ( !grb ) return NULL;
++
++   _mesa_init_renderbuffer(&grb->base, 0);
++   grb->base.ClassID = GLAMO_RB_CLASS;
++
++   switch (format) {
++      case GL_RGB5:
++         grb->base.Format = MESA_FORMAT_RGB565;
++         grb->base._BaseFormat = GL_RGB;
++
++         grb->base.DataType = GL_UNSIGNED_BYTE;
++         break;
++      case GL_DEPTH_COMPONENT16:
++         grb->base.DataType = GL_UNSIGNED_SHORT;
++	 grb->base._BaseFormat = GL_DEPTH_COMPONENT;
++         break;
++      default:
++         fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
++         _mesa_delete_renderbuffer(&grb->base);
++         return NULL;
++   }
++
++   grb->dPriv = driDrawPriv;
++   grb->base.InternalFormat = format;
++
++   grb->base.Delete = glamo_delete_renderbuffer;
++   grb->base.AllocStorage = glamo_alloc_window_storage;
++   grb->base.GetPointer = glamo_get_pointer;
++
++   return grb;
++}
++
++
++void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
++                               struct glamo_bo *bo)
++{
++  struct glamo_bo *old;
++  old = grb->bo;
++  grb->bo = bo;
++  glamo_bo_ref(bo);
++  if ( old ) glamo_bo_unref(old);
++}
++
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h
+new file mode 100644
+index 0000000..48210dd
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h
+@@ -0,0 +1,77 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_FBO_H
++#define __GLAMO_FBO_H
++
++
++#include "main/mtypes.h"
++#include "dri_util.h"
++
++
++/* This is just a marker so we can tell a Glamo renderbuffer from a Mesa one */
++#define GLAMO_RB_CLASS (0xdeadbeef)
++
++
++struct glamo_renderbuffer
++{
++	struct gl_renderbuffer base;   /* Must be first */
++	struct glamo_bo *bo;
++	unsigned int cpp;
++	unsigned int pitch;
++	unsigned int width;
++	unsigned int height;
++
++	__DRIdrawable *dPriv;
++};
++
++
++struct glamo_framebuffer
++{
++	struct gl_framebuffer base;
++	struct glamo_renderbuffer *color_rb[2];
++};
++
++
++/* This is just a small wrapper function to return NULL if the gl_renderbuffer
++ * is not a glamo_renderbuffer */
++static inline struct glamo_renderbuffer
++                                 *glamo_renderbuffer(struct gl_renderbuffer *rb)
++{
++	struct glamo_renderbuffer *grb = (struct glamo_renderbuffer *)rb;
++	if ( grb && grb->base.ClassID == GLAMO_RB_CLASS )
++		return grb;
++	else
++		return NULL;
++}
++
++
++extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
++                                             __DRIdrawable *driDrawPriv);
++
++extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
++                               struct glamo_bo *bo);
++
++#endif   /* __GLAMO_FBO_H */
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_regs.h b/src/mesa/drivers/dri/glamo/glamo_regs.h
+new file mode 100644
+index 0000000..02b2294
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_regs.h
+@@ -0,0 +1,174 @@
++#ifndef _GLAMO_REGS_H
++#define _GLAMO_REGS_H
++
++/* Smedia Glamo 336x/337x driver
++ *
++ * (C) 2007 by OpenMoko, Inc.
++ * Author: Harald Welte <laforge@openmoko.org>
++ * All rights reserved.
++ *
++ * Modified for Glamo Mesa driver by Thomas White <taw@bitwiz.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++enum glamo_regster_offsets {
++	GLAMO_REGOFS_GENERIC	= 0x0000,
++	GLAMO_REGOFS_HOSTBUS	= 0x0200,
++	GLAMO_REGOFS_MEMORY	= 0x0300,
++	GLAMO_REGOFS_VIDCAP	= 0x0400,
++	GLAMO_REGOFS_ISP	= 0x0500,
++	GLAMO_REGOFS_JPEG	= 0x0800,
++	GLAMO_REGOFS_MPEG	= 0x0c00,
++	GLAMO_REGOFS_LCD	= 0x1100,
++	GLAMO_REGOFS_MMC	= 0x1400,
++	GLAMO_REGOFS_MPROC0	= 0x1500,
++	GLAMO_REGOFS_MPROC1	= 0x1580,
++	GLAMO_REGOFS_CMDQUEUE	= 0x1600,
++	GLAMO_REGOFS_RISC	= 0x1680,
++	GLAMO_REGOFS_2D		= 0x1700,
++	GLAMO_REGOFS_3D		= 0x1b00,
++};
++
++
++#define REG_MPEG(x)           (GLAMO_REGOFS_MPEG+(x))
++
++enum glamo_register_mpeg {
++      //
++      GLAMO_REG_MPEG_DC_ADDRL         = REG_MPEG(0x3c),
++      GLAMO_REG_MPEG_DC_ADDRH         = REG_MPEG(0x3e),
++      GLAMO_REG_MPEG_AC_ADDRL         = REG_MPEG(0x40),
++      GLAMO_REG_MPEG_AC_ADDRH         = REG_MPEG(0x42),
++      //
++      GLAMO_REG_MPEG_SAFE_1           = REG_MPEG(0x60),
++      GLAMO_REG_MPEG_SAFE_2           = REG_MPEG(0x62),
++      GLAMO_REG_MPEG_SAFE_3           = REG_MPEG(0x64),
++      //
++      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRL = REG_MPEG(0x6e),
++      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRH = REG_MPEG(0x70),
++      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRL = REG_MPEG(0x72),
++      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRH = REG_MPEG(0x74),
++      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRL = REG_MPEG(0x76),
++      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRH = REG_MPEG(0x78),
++      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRL = REG_MPEG(0x7a),
++      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRH = REG_MPEG(0x7c),
++      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRL = REG_MPEG(0x7e),
++      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRH = REG_MPEG(0x80),
++      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRL = REG_MPEG(0x82),
++      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRH = REG_MPEG(0x84),
++      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRL = REG_MPEG(0x86),
++      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRH = REG_MPEG(0x88),
++      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRL = REG_MPEG(0x8a),
++      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRH = REG_MPEG(0x8c),
++      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRL = REG_MPEG(0x8e),
++      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRH = REG_MPEG(0x90),
++      GLAMO_REG_MPEG_DEC_WIDTH        = REG_MPEG(0x92),
++      GLAMO_REG_MPEG_DEC_HEIGHT       = REG_MPEG(0x94),
++      GLAMO_REG_MPEG_SPECIAL          = REG_MPEG(0x96),
++      GLAMO_REG_MPEG_DEC_IN_ADDRL     = REG_MPEG(0x98),
++      GLAMO_REG_MPEG_DEC_IN_ADDRH     = REG_MPEG(0x9a),
++      //
++      GLAMO_REG_MPEG_DEBLK_THRESHOLD  = REG_MPEG(0xc0),
++      //
++      GLAMO_REG_MPEG_DEC_STATUS       = REG_MPEG(0xc8),
++      GLAMO_REG_MPEG_DEC_RB0          = REG_MPEG(0xca),
++      GLAMO_REG_MPEG_DEC_RB1          = REG_MPEG(0xcc),
++};
++
++
++#define REG_2D(x)		(GLAMO_REGOFS_2D+(x))
++
++enum glamo_register_2d {
++	GLAMO_REG_2D_SRC_ADDRL		= REG_2D(0x00),
++	GLAMO_REG_2D_SRC_ADDRH		= REG_2D(0x02),
++	GLAMO_REG_2D_SRC_PITCH		= REG_2D(0x04),
++	GLAMO_REG_2D_SRC_X		= REG_2D(0x06),
++	GLAMO_REG_2D_SRC_Y		= REG_2D(0x08),
++	GLAMO_REG_2D_DST_X		= REG_2D(0x0a),
++	GLAMO_REG_2D_DST_Y		= REG_2D(0x0c),
++	GLAMO_REG_2D_DST_ADDRL		= REG_2D(0x0e),
++	GLAMO_REG_2D_DST_ADDRH		= REG_2D(0x10),
++	GLAMO_REG_2D_DST_PITCH		= REG_2D(0x12),
++	GLAMO_REG_2D_DST_HEIGHT		= REG_2D(0x14),
++	GLAMO_REG_2D_RECT_WIDTH		= REG_2D(0x16),
++	GLAMO_REG_2D_RECT_HEIGHT	= REG_2D(0x18),
++	GLAMO_REG_2D_PAT_ADDRL		= REG_2D(0x1a),
++	GLAMO_REG_2D_PAT_ADDRH		= REG_2D(0x1c),
++	GLAMO_REG_2D_PAT_FG		= REG_2D(0x1e),
++	GLAMO_REG_2D_PAT_BG		= REG_2D(0x20),
++	GLAMO_REG_2D_SRC_FG		= REG_2D(0x22),
++	GLAMO_REG_2D_SRC_BG		= REG_2D(0x24),
++	GLAMO_REG_2D_MASK1		= REG_2D(0x26),
++	GLAMO_REG_2D_MASK2		= REG_2D(0x28),
++	GLAMO_REG_2D_MASK3		= REG_2D(0x2a),
++	GLAMO_REG_2D_MASK4		= REG_2D(0x2c),
++	GLAMO_REG_2D_ROT_X		= REG_2D(0x2e),
++	GLAMO_REG_2D_ROT_Y		= REG_2D(0x30),
++	GLAMO_REG_2D_LEFT_CLIP		= REG_2D(0x32),
++	GLAMO_REG_2D_TOP_CLIP		= REG_2D(0x34),
++	GLAMO_REG_2D_RIGHT_CLIP		= REG_2D(0x36),
++	GLAMO_REG_2D_BOTTOM_CLIP	= REG_2D(0x38),
++	GLAMO_REG_2D_COMMAND1		= REG_2D(0x3A),
++	GLAMO_REG_2D_COMMAND2		= REG_2D(0x3C),
++	GLAMO_REG_2D_COMMAND3		= REG_2D(0x3E),
++	GLAMO_REG_2D_SAFE		= REG_2D(0x40),
++	GLAMO_REG_2D_STATUS		= REG_2D(0x42),
++	GLAMO_REG_2D_ID1		= REG_2D(0x44),
++	GLAMO_REG_2D_ID2		= REG_2D(0x46),
++	GLAMO_REG_2D_ID3		= REG_2D(0x48),
++};
++
++
++/* No offset this time */
++#define REG_3D(x)		(x)
++
++enum glamo_register_3d
++{
++	/* Fire the engine */
++	G3D_FIRE			= REG_3D(0x2058),
++
++	/* Streams of vertex/colour/normal/texcoord data */
++	G3D_ACTIVE_STREAMS		= REG_3D(0x1f00),
++	G3D_LAST_STREAM__VCOLFMT	= REG_3D(0x2030),
++	G3D_STREAM_MODE_0		= REG_3D(0x1f10),
++	G3D_STREAM_BASE_0		= REG_3D(0x1f14),
++	G3D_STREAM_MODE_1		= REG_3D(0x1f18),
++	G3D_STREAM_BASE_1		= REG_3D(0x1f1c),
++	G3D_STREAM_MODE_2		= REG_3D(0x1f20),
++	G3D_STREAM_BASE_2		= REG_3D(0x1f24),
++	G3D_STREAM_MODE_3		= REG_3D(0x1f28),
++	G3D_STREAM_BASE_3		= REG_3D(0x1f2c),
++	G3D_STREAM_MODE_4		= REG_3D(0x1f30),
++	G3D_STREAM_BASE_4		= REG_3D(0x1f34),
++	G3D_STREAM_MODE_5		= REG_3D(0x1f38),
++	G3D_STREAM_BASE_5		= REG_3D(0x1f3c),
++	G3D_STREAM_MODE_6		= REG_3D(0x1f40),
++	G3D_STREAM_BASE_6		= REG_3D(0x1f44),
++	G3D_STREAM_MODE_7		= REG_3D(0x1f48),
++	G3D_STREAM_BASE_7		= REG_3D(0x1f4c),
++
++	/* Modelview*projection matrix */
++	G3D_MATRIX_MVP			= REG_3D(0x26a0), /* .. 0x27df */
++
++	/* Modelview matrix */
++	G3D_MATRIX_MV			= REG_3D(0x26e0), /* .. 0x270f */
++
++	/* Inverse MVP, 3x3 only */
++	G3D_MATRIX_IMVP			= REG_3D(0x2710), /* .. 0x2733 */
++
++};
++
++#endif /* _GLAMO_REGS_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c
+new file mode 100644
+index 0000000..fd52418
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_render.c
+@@ -0,0 +1,230 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS 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.
++ *
++ *
++ * Based on intel_render.c, to which the following notice applies:
++ *
++ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS 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.
++ *
++ */
++
++
++/*
++ * Render unclipped vertex buffers by emitting vertices directly to
++ * dma buffers.  Use strip/fan hardware acceleration where possible.
++ *
++ */
++#include "main/glheader.h"
++#include "main/context.h"
++#include "main/macros.h"
++#include "main/imports.h"
++#include "main/mtypes.h"
++#include "main/enums.h"
++
++#include "tnl/t_context.h"
++#include "tnl/t_vertex.h"
++#include "tnl/t_pipeline.h"
++
++#include "glamo_context.h"
++#include "glamo_tris.h"
++#include "glamo_regs.h"
++
++/*
++ * Render unclipped vertex buffers by emitting vertices directly to
++ * VRAM buffers.  Use strip/fan hardware primitives where possible.
++ * Try to simulate missing primitives with indexed vertices.
++ */
++#define HAVE_POINTS      1
++#define HAVE_LINES       1
++#define HAVE_LINE_STRIPS 0
++#define HAVE_TRIANGLES   1
++#define HAVE_TRI_STRIPS  0
++#define HAVE_TRI_STRIP_1 0
++#define HAVE_TRI_FANS    0
++#define HAVE_POLYGONS    0
++#define HAVE_QUADS       0
++#define HAVE_QUAD_STRIPS 0
++#define HAVE_ELTS        0
++
++
++static void glamoFlushPrim(struct glamo_context *gCtx)
++{
++	printf("glamoFlushPrim: %i vertices, %i %i\n", gCtx->prim.count,
++	gCtx->prim.start_offset, gCtx->prim.current_offset);
++
++	if ( gCtx->prim.vb_bo == NULL ) return;
++
++	/* Upload to hardware */
++	glamo_bo_subdata(gCtx->prim.vb_bo, 0, gCtx->prim.current_offset,
++	                 gCtx->prim.vb);
++
++	/* Dispatch to the hardware */
++	glamoDRMStartBurst(gCtx, G3D_STREAM_MODE_0);
++	glamoDRMAddData(gCtx, 0x000f0300, 4);
++	glamoDRMAddBO(gCtx, gCtx->prim.vb_bo);
++	glamoDRMDispatch(gCtx);
++
++	/* Please use a new BO for the next buffer */
++	gCtx->prim.vb_bo = NULL;
++
++	/* Continue from new start */
++	gCtx->prim.start_offset = gCtx->prim.current_offset;
++}
++
++
++static inline GLuint glamoGetVBMax(struct glamo_context *gCtx)
++{
++	return GLAMO_VB_SIZE / gCtx->vertex_size;
++}
++
++
++static inline GLuint glamoGetCurrentMax(struct glamo_context *gCtx)
++{
++	/* How many more vertices can be accommodated?
++	 * Each vertex takes up 4x 32-bit fixed point values */
++	return (GLAMO_VB_SIZE - gCtx->prim.current_offset) / gCtx->vertex_size;
++}
++
++
++#define LOCAL_VARS \
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++#define INIT(prim)
++
++#define FLUSH() glamoFlushPrim(gCtx)
++
++#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx)
++#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx)
++
++#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr)
++
++#define EMIT_VERTS(ctx, j, nr, buf) \
++	_tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
++
++#define TAG(x) glamo_##x
++#include "tnl_dd/t_dd_dmatmp.h"
++
++
++/**********************************************************************/
++/*                          Render pipeline stage                     */
++/**********************************************************************/
++
++static void glamoFireEngine(struct glamo_context *gCtx)
++{
++	glamoDRMStartBurst(gCtx, G3D_FIRE);
++	glamoDRMAddData(gCtx, 0, 2);  /* Fire! */
++	glamoDRMDispatch(gCtx);
++}
++
++
++static GLboolean glamoRunRender(GLcontext *ctx,
++                                struct tnl_pipeline_stage *stage)
++{
++	TNLcontext *tnl = TNL_CONTEXT(ctx);
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	struct vertex_buffer *VB = &tnl->vb;
++	GLuint i;
++
++	printf("glamoRunRender\n");
++
++	/* Don't handle clipping */
++	if ( !glamo_validate_render(ctx, VB) ) {
++		return GL_TRUE; /* Failed */
++	}
++
++	/* Validate GPU state */
++	if ( gCtx->new_state ) {
++		if ( !glamoValidateState(ctx, gCtx->new_state) ) {
++			printf("Couldn't validate state...\n");
++		}
++	} /* else nothing to update */
++
++	tnl->clipspace.new_inputs |= VERT_BIT_POS;
++
++	tnl->Driver.Render.Start(ctx);
++
++	for ( i=0; i<VB->PrimitiveCount; i++ ) {
++
++		GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
++		GLuint start = VB->Primitive[i].start;
++		GLuint length = VB->Primitive[i].count;
++
++		if (!length) continue;
++
++		glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start,
++                                                     start + length, prim);
++
++	}
++
++	tnl->Driver.Render.Finish(ctx);
++
++	glamoFireEngine(gCtx);
++
++	return GL_FALSE;  /* Ok */
++}
++
++
++static const struct tnl_pipeline_stage _glamo_render_stage = {
++	"glamo render",
++	NULL,
++	NULL,
++	NULL,
++	NULL,
++	glamoRunRender
++};
++
++
++const struct tnl_pipeline_stage *glamo_pipeline[] = {
++	&_tnl_vertex_transform_stage,
++	&_tnl_vertex_cull_stage,
++	&_tnl_normal_transform_stage,
++	&_tnl_lighting_stage,
++	&_tnl_fog_coordinate_stage,
++	&_tnl_texgen_stage,
++	&_tnl_texture_transform_stage,
++	&_tnl_point_attenuation_stage,
++	&_tnl_vertex_program_stage,
++	&_glamo_render_stage,        /* ADD: unclipped rastersetup-to-dma */
++	&_tnl_render_stage,
++	0,
++};
+diff --git a/src/mesa/drivers/dri/glamo/glamo_render.h b/src/mesa/drivers/dri/glamo/glamo_render.h
+new file mode 100644
+index 0000000..99c36a8
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_render.h
+@@ -0,0 +1,31 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_RENDER_H
++#define __GLAMO_RENDER_H
++
++#include "main/mtypes.h"
++
++extern const struct tnl_pipeline_stage *glamo_pipeline[];
++
++#endif   /* __GLAMO_RENDER_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
+new file mode 100644
+index 0000000..39148f3
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
+@@ -0,0 +1,250 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_screen.c (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "dri_util.h"
++#include "utils.h"
++#include "xmlconfig.h"
++#include "GL/internal/dri_interface.h"
++#include "main/framebuffer.h"
++#include "main/renderbuffer.h"
++
++#include "glamo_screen.h"
++#include "glamo_context.h"
++#include "glamo_fbo.h"
++
++/* This comes from libdrm_glamo */
++#include <glamo_bo_gem.h>
++
++
++static int glamoInitDriver(__DRIscreen *psp)
++{
++   return 0;
++}
++
++
++static glamoScreenPtr glamoCreateScreen(__DRIscreen *sPriv)
++{
++   glamoScreenPtr glamoScreen;
++
++   /* Allocate the private area */
++   glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen));
++   if ( glamoScreen == NULL )
++      return NULL;
++
++   glamoScreen->driScreen = sPriv;
++
++   /* This is our link to the kernel's memory manager, via libdrm */
++   glamoScreen->bom = glamo_bo_manager_gem_ctor(sPriv->fd);
++
++   return glamoScreen;
++}
++
++
++static void glamoDestroyScreen(__DRIscreen *sPriv)
++{
++   glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private;
++
++   if ( glamoScreen == NULL )
++      return;
++
++   FREE(glamoScreen);
++   sPriv->private = NULL;
++}
++
++
++static const __DRIconfig **glamoInitScreen(__DRIscreen *sPriv)
++{
++   __DRIconfig **configs;
++   uint8_t depth_bits_array[2];
++   uint8_t stencil_bits_array[2];
++   uint8_t msaa_samples_array[1];
++   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
++
++   /* Driver initialisation */
++   if ( glamoInitDriver(sPriv) ) {
++      return NULL;
++   }
++
++   /* Screen-specific initialisation */
++   sPriv->private = glamoCreateScreen(sPriv);
++   if ( !sPriv->private ) {
++      glamoDestroyScreen(sPriv);
++      return NULL;
++   }
++
++   depth_bits_array[0] = 0;
++   stencil_bits_array[0] = 0;
++   depth_bits_array[1] = 16;
++   stencil_bits_array[1] = 0;
++   msaa_samples_array[0] = 0;
++
++   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
++                           depth_bits_array, stencil_bits_array, 2,
++                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
++
++   if ( configs == NULL ) {
++      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
++      return NULL;
++   }
++
++   return (const __DRIconfig **)configs;
++}
++
++
++static const __DRIconfig **glamoInitScreen2(__DRIscreen *sPriv)
++{
++   __DRIconfig **configs;
++   uint8_t depth_bits_array[2];
++   uint8_t stencil_bits_array[2];
++   uint8_t msaa_samples_array[1];
++   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
++
++   /* Driver initialisation */
++   if ( glamoInitDriver(sPriv) ) {
++      return NULL;
++   }
++
++   /* Screen-specific initialisation */
++   sPriv->private = glamoCreateScreen(sPriv);
++   if ( !sPriv->private ) {
++      glamoDestroyScreen(sPriv);
++      return NULL;
++   }
++
++   depth_bits_array[0] = 0;
++   stencil_bits_array[0] = 0;
++   depth_bits_array[1] = 16;
++   stencil_bits_array[1] = 0;
++   msaa_samples_array[0] = 0;
++
++   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
++                           depth_bits_array, stencil_bits_array, 2,
++                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
++
++   if ( configs == NULL ) {
++      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
++      return NULL;
++   }
++
++   return (const __DRIconfig **)configs;
++}
++
++
++/* Allocate buffers for a context.  This is where the fun starts... */
++static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
++                                   __DRIdrawable *driDrawPriv,
++                                   const __GLcontextModes *mesaVis,
++                                   GLboolean isPixmap)
++{
++   struct glamo_framebuffer *gfb;
++   GLenum rgbFormat;
++
++   if ( isPixmap ) return GL_FALSE; /* not implemented */
++
++   gfb = CALLOC_STRUCT(glamo_framebuffer);
++   if ( !gfb ) return GL_FALSE;
++
++   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
++
++   /* we only support this one format at the moment */
++   rgbFormat = GL_RGB5;
++
++   /* Front color renderbuffer */
++   gfb->color_rb[0] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
++   _mesa_add_renderbuffer(&gfb->base, BUFFER_FRONT_LEFT,
++                          &gfb->color_rb[0]->base);
++
++   /* Back color renderbuffer, if requested */
++   if ( mesaVis->doubleBufferMode ) {
++      gfb->color_rb[1] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
++      _mesa_add_renderbuffer(&gfb->base, BUFFER_BACK_LEFT,
++                             &gfb->color_rb[1]->base);
++   }
++
++   if ( mesaVis->depthBits == 16 ) {
++      struct glamo_renderbuffer *depth;
++      depth = glamo_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
++      _mesa_add_renderbuffer(&gfb->base, BUFFER_DEPTH, &depth->base);
++   }
++
++   /* Add software renderbuffers for the things we can't support in hardware */
++   _mesa_add_soft_renderbuffers(&gfb->base,
++      GL_FALSE,  /* color */
++      GL_FALSE,  /* depth */
++      mesaVis->stencilBits > 0,   /* stencil, if required */
++      mesaVis->accumRedBits > 0,  /* accum, if required */
++      GL_FALSE,  /* alpha */
++      GL_FALSE   /* aux */
++   );
++   driDrawPriv->driverPrivate = (void *)gfb;
++
++   return (driDrawPriv->driverPrivate != NULL);
++}
++
++
++static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
++{
++}
++
++
++static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
++{
++   printf("glamoSwapBuffers\n"); fflush(stdout);
++}
++
++
++/*
++ *  Mesa entry points
++ *
++ *  See src/mesa/drivers/dri/common/dri_util.h for information about these
++ */
++const struct __DriverAPIRec driDriverAPI = {
++   .InitScreen      = glamoInitScreen,
++   .DestroyScreen   = glamoDestroyScreen,
++   .CreateContext   = glamoCreateContext,
++   .DestroyContext  = glamoDestroyContext,
++   .CreateBuffer    = glamoCreateBuffer,
++   .DestroyBuffer   = glamoDestroyBuffer,
++   .SwapBuffers     = glamoSwapBuffers,
++   .MakeCurrent     = glamoMakeCurrent,
++   .UnbindContext   = glamoUnbindContext,
++   .GetSwapInfo     = NULL,   /* Not used */
++   .WaitForMSC      = NULL,
++   .WaitForSBC      = NULL,
++   .SwapBuffersMSC  = NULL,
++   .CopySubBuffer   = NULL,
++   .GetDrawableMSC  = NULL,   /* Not used */
++   .InitScreen2     = glamoInitScreen2,    /* For DRI2 */
++};
++
++/* This is the table of extensions that the loader will dlsym() for. */
++PUBLIC const __DRIextension *__driDriverExtensions[] = {
++    &driCoreExtension.base,
++    &driLegacyExtension.base,
++    &driDRI2Extension.base,
++    NULL
++};
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h
+new file mode 100644
+index 0000000..3f2eb5f
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_screen.h
+@@ -0,0 +1,44 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_screen.h (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_SCREEN_H
++#define __GLAMO_SCREEN_H
++
++#include "xmlconfig.h"
++#include "dri_util.h"
++
++#include <glamo_bo_gem.h>
++
++typedef struct {
++
++   __DRIscreen *driScreen;
++   driOptionCache optionCache;
++
++   struct glamo_bo_manager *bom;
++
++} glamoScreenRec, *glamoScreenPtr;
++
++#endif   /* __GLAMO_SCREEN_H */
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c
+new file mode 100644
+index 0000000..4046c24
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_state.c
+@@ -0,0 +1,304 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009-2010 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_state.c (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS 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.
++ *
++ *
++ * Also partially based on intel_fbo.c, to which the following notice applies:
++ *
++ * Copyright 2006 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "main/context.h"
++#include "main/framebuffer.h"
++#include "main/api_arrayelt.h"
++#include "swrast/swrast.h"
++#include "swrast_setup/swrast_setup.h"
++#include "tnl/tnl.h"
++
++#include "glamo_fbo.h"
++#include "glamo_state.h"
++#include "glamo_context.h"
++#include "glamo_cmdq.h"
++#include "glamo_regs.h"
++
++
++static void glamoResizeBuffers(GLcontext *ctx, struct gl_framebuffer *fb,
++                               GLuint width, GLuint height)
++{
++	struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb;
++	int i;
++
++	_mesa_resize_framebuffer(ctx, fb, width, height);
++
++	fb->Initialized = GL_TRUE; /* XXX remove someday */
++
++	if (fb->Name != 0) {
++		return;
++	}
++
++	/* Make sure all window system renderbuffers are up to date */
++	for (i = 0; i < 2; i++) {
++		struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base;
++
++		/* only resize if size is changing */
++		if (rb && (rb->Width != width || rb->Height != height)) {
++			rb->AllocStorage(ctx, rb, rb->InternalFormat,
++		                         width, height);
++		}
++	}
++}
++
++
++static void glamoClear(GLcontext *ctx, GLbitfield mask)
++{
++	glamoContext *gCtx;
++	struct gl_framebuffer *fb;
++	int i;
++
++	gCtx = GLAMO_CONTEXT(ctx);
++	fb = ctx->DrawBuffer;
++
++	printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0],
++	       ctx->Color.ClearColor[1], ctx->Color.ClearColor[2],
++	       ctx->Color.ClearColor[3]); fflush(stdout);
++
++	for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
++
++		struct glamo_renderbuffer *grb;
++
++		grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]);
++
++		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_DST_X);
++		glamoDRMAddData(gCtx, fb->_Xmin, 2);           /* dest X */
++		glamoDRMAddData(gCtx, fb->_Ymin, 2);           /* dest Y */
++		glamoDRMAddBO(gCtx, grb->bo);                  /* dest L/H */
++		glamoDRMAddData(gCtx, grb->pitch & 0x7ff, 2);  /* dest pitch */
++		glamoDRMAddData(gCtx, grb->height, 2);         /* dest height */
++		glamoDRMAddData(gCtx, fb->_Xmax-fb->_Xmin, 2); /* width */
++		glamoDRMAddData(gCtx, fb->_Ymax-fb->_Ymin, 2); /* height */
++		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt L */
++		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt H */
++		glamoDRMAddData(gCtx, gCtx->col_clear, 2);     /* FG colour */
++		glamoDRMDispatch(gCtx);
++
++		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_COMMAND1);
++		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 1 */
++		glamoDRMAddData(gCtx, 0xf0 << 8, 2); /* Cmd param 2 */
++		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 3 */
++		glamoDRMDispatch(gCtx);
++
++	}
++}
++
++
++static void glamoClearColor(GLcontext *ctx, const GLfloat color[4])
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	GLubyte col_byte[4];
++
++	printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2],
++	       color[3]); fflush(stdout);
++
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]);
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]);
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]);
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]);
++
++	gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1],
++	                                     col_byte[2]);
++}
++
++
++static void glamoShadeModel(GLcontext *ctx, GLenum mode)
++{
++	printf("glamoShadeModel\n"); fflush(stdout);
++}
++
++
++static void glamoViewport(GLcontext *ctx, GLint x, GLint y,
++                          GLsizei width, GLsizei height )
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	__DRIcontext *driContext = gCtx->driContext;
++	void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
++			 GLsizei w, GLsizei h);
++
++	if ( !driContext->driScreenPriv->dri2.enabled ) return;
++
++	/* TODO: Flush before fiddling with fake front buffer */
++
++	if ( ctx->DrawBuffer->Name == 0 ) {
++
++		glamo_update_renderbuffers(driContext,
++		                           driContext->driDrawablePriv);
++		if ( driContext->driDrawablePriv
++		                              != driContext->driReadablePriv ) {
++			glamo_update_renderbuffers(driContext,
++				                   driContext->driReadablePriv);
++		}
++
++	}
++
++	old_viewport = ctx->Driver.Viewport;
++	ctx->Driver.Viewport = NULL;
++	gCtx->driDrawable = driContext->driDrawablePriv;
++	ctx->Driver.Viewport = old_viewport;
++}
++
++
++static void glamoUploadMatrix(struct glamo_context *gCtx, uint16_t mreg,
++                              GLfloat *matrix)
++{
++	int i;
++	char *type;
++
++	switch ( mreg ) {
++	case G3D_MATRIX_MVP :
++		type = "MVP"; break;
++	case G3D_MATRIX_MV :
++		type = "MV"; break;
++	case G3D_MATRIX_IMVP :
++		type = "inverse MVP"; break;
++	default :
++		type = "unknown"; break;
++	}
++	printf("Uploading %s matrix...\n", type);
++
++	glamoDRMStartBurst(gCtx, mreg);
++	if ( mreg != G3D_MATRIX_IMVP ) {
++		for ( i=0; i<16; i++ ) {
++			glamoDRMAddData(gCtx, float7s16(matrix[i]), 4);
++		}
++	} else {
++		/* Normal matrix needs special treatment */
++		for ( i=0; i<3; i++ ) {
++			glamoDRMAddData(gCtx, float7s16(matrix[4*i]), 4);
++			glamoDRMAddData(gCtx, float7s16(matrix[4*i+1]), 4);
++			glamoDRMAddData(gCtx, float7s16(matrix[4*i+2]), 4);
++		}
++	}
++	glamoDRMDispatch(gCtx);
++}
++
++
++GLboolean glamoValidateState(GLcontext *ctx, GLuint new_state)
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++	if ( new_state & (_NEW_MODELVIEW|_NEW_PROJECTION) ) {
++
++		glamoUploadMatrix(gCtx, G3D_MATRIX_MVP,
++		                  ctx->_ModelProjectMatrix.m);
++
++		/* FIXME: The following two aren't needed unless lighting
++		 * is in use... */
++		glamoUploadMatrix(gCtx, G3D_MATRIX_MV,
++		                  ctx->ModelviewMatrixStack.Top->m);
++		_math_matrix_alloc_inv(&(ctx->_ModelProjectMatrix));
++		_math_matrix_analyse(&(ctx->_ModelProjectMatrix));
++		glamoUploadMatrix(gCtx, G3D_MATRIX_IMVP,
++		                  ctx->_ModelProjectMatrix.inv);
++	}
++
++	gCtx->new_state = 0;
++	return GL_TRUE;
++}
++
++
++static void glamoUpdateState(GLcontext *ctx, GLbitfield new_state)
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++	printf("glamoUpdateState\n");
++
++	_swrast_InvalidateState(ctx, new_state);
++	_swsetup_InvalidateState(ctx, new_state);
++	_vbo_InvalidateState(ctx, new_state);
++	_tnl_InvalidateState(ctx, new_state);
++	_ae_invalidate_state(ctx, new_state);
++
++	/* Make a note that some state has changed,
++	 * so that it can be sent to the GPU later. */
++	gCtx->new_state |= new_state;
++}
++
++
++static void glamoFlush(GLcontext *ctx)
++{
++	printf("glamoFlush\n");
++}
++
++
++void glamoInitStateFuncs(GLcontext *ctx)
++{
++	ctx->Driver.UpdateState       = glamoUpdateState;
++	ctx->Driver.Clear             = glamoClear;
++	ctx->Driver.ClearColor        = glamoClearColor;
++	ctx->Driver.ClearDepth        = NULL;
++	ctx->Driver.ClearStencil      = NULL;
++	ctx->Driver.AlphaFunc         = NULL;
++	ctx->Driver.BlendFuncSeparate = NULL;
++	ctx->Driver.ColorMask         = NULL;
++	ctx->Driver.CullFace          = NULL;
++	ctx->Driver.DepthMask         = NULL;
++	ctx->Driver.DepthFunc         = NULL;
++	ctx->Driver.DepthRange        = NULL;
++	ctx->Driver.DrawBuffer        = NULL;
++	ctx->Driver.Enable            = NULL;
++	ctx->Driver.FrontFace         = NULL;
++	ctx->Driver.Fogfv             = NULL;
++	ctx->Driver.Hint              = NULL;
++	ctx->Driver.Lightfv           = NULL;
++	ctx->Driver.LogicOpcode       = NULL;
++	ctx->Driver.PolygonMode       = NULL;
++	ctx->Driver.PolygonStipple    = NULL;
++	ctx->Driver.ReadBuffer        = NULL;
++	ctx->Driver.RenderMode        = NULL;
++	ctx->Driver.Scissor           = NULL;
++	ctx->Driver.ShadeModel        = glamoShadeModel;
++	ctx->Driver.LightModelfv      = NULL;
++	ctx->Driver.Viewport          = glamoViewport;
++	ctx->Driver.ResizeBuffers     = glamoResizeBuffers;
++	ctx->Driver.Flush             = glamoFlush;
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_state.h b/src/mesa/drivers/dri/glamo/glamo_state.h
+new file mode 100644
+index 0000000..98f0b97
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_state.h
+@@ -0,0 +1,34 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_state.h (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_STATE_H
++#define __GLAMO_STATE_H
++
++#include "main/context.h"
++
++extern void glamoInitStateFuncs(GLcontext *ctx);
++
++#endif   /* __GLAMO_STATE_H */
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.c b/src/mesa/drivers/dri/glamo/glamo_tris.c
+new file mode 100644
+index 0000000..6c6b5a6
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_tris.c
+@@ -0,0 +1,310 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS 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.
++ *
++ *
++ * Based on intel_tris.c, to which the following notice applies:
++ *
++ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ *
++ */
++
++
++#include <glamo_bo.h>
++#include <glamo_bo_gem.h>
++#include <glamo_drm.h>
++
++#include "main/mtypes.h"
++#include "swrast/swrast.h"
++#include "tnl/t_context.h"
++#include "tnl/t_vertex.h"
++#include "tnl/t_pipeline.h"
++
++#include "glamo_tris.h"
++#include "glamo_context.h"
++
++
++static void glamoRunPipeline(GLcontext *ctx)
++{
++	printf("glamoRunPipeline\n");
++
++	/* TODO: Emit state */
++
++	_tnl_run_pipeline(ctx);
++}
++
++
++static void glamoRenderStart(GLcontext *ctx)
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++	/* Decide which attributes will be used */
++	gCtx->vertex_attrs[0].attrib = _TNL_ATTRIB_POS;
++	gCtx->vertex_attrs[0].format = EMIT_4F;
++
++	gCtx->vertex_size = _tnl_install_attrs(ctx, gCtx->vertex_attrs, 1,
++	                                       NULL, 0);
++}
++
++
++static void glamoRenderFinish(GLcontext *ctx)
++{
++	printf("glamoRenderFinish\n");
++}
++
++
++static void glamoPrimitiveNotify(GLcontext *ctx, GLenum prim)
++{
++	printf("glamoPrimitiveNotify\n");
++}
++
++
++uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, unsigned int count)
++{
++	uint32_t *addr;
++
++	printf("glamoGetPrimSpace\n");
++
++	/* Check for space in the existing VB */
++	if (gCtx->prim.vb_bo == NULL || (gCtx->prim.current_offset +
++	                           count * gCtx->vertex_size) > GLAMO_VB_SIZE) {
++
++		/* Not enough space, or no VB existing. Start a new one... */
++		if (gCtx->prim.vb == NULL) {
++			printf("Allocated %i bytes\n", GLAMO_VB_SIZE);
++			gCtx->prim.vb = malloc(GLAMO_VB_SIZE);
++		}
++		gCtx->prim.vb_bo = glamo_bo_open(gCtx->glamoScreen->bom, 0,
++		                                 GLAMO_VB_SIZE, 4,
++		                                 GLAMO_GEM_DOMAIN_VRAM, 0);
++		gCtx->prim.start_offset = 0;
++		gCtx->prim.current_offset = 0;
++	}
++
++	addr = (uint32_t *)(gCtx->prim.vb + gCtx->prim.current_offset);
++	gCtx->prim.current_offset += gCtx->vertex_size * count;
++	gCtx->prim.count += count;
++
++	return addr;
++}
++
++
++#define COPY_DWORDS( j, vb, vertsize, v )	\
++do {						\
++   for ( j = 0 ; j < vertsize ; j++ ) {		\
++      vb[j] = ((GLuint *)v)[j];			\
++   }						\
++   vb += vertsize;				\
++} while (0)
++
++
++static void glamo_draw_triangle(struct glamo_context *gCtx,
++                                glamoVertexPtr v0, glamoVertexPtr v1,
++                                glamoVertexPtr v2)
++{
++	GLuint *vb = glamoGetPrimSpace(gCtx, 3);
++	int j;
++
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v2);
++}
++
++
++static void glamo_draw_line(struct glamo_context *gCtx,
++                            glamoVertexPtr v0, glamoVertexPtr v1)
++{
++	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
++	int j;
++
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
++}
++
++
++static void glamo_draw_point(struct glamo_context *gCtx, glamoVertexPtr v0)
++{
++	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
++	int j;
++
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
++}
++
++
++#define TRI( a, b, c )                          \
++do {                                            \
++        glamo_draw_triangle(gCtx, a, b, c  );   \
++} while (0)
++
++
++#define QUAD( a, b, c, d )                      \
++printf("Drawing a quad\n");                     \
++do {                                            \
++        glamo_draw_triangle(gCtx, a, b, d);     \
++        glamo_draw_triangle(gCtx, b, c, d);     \
++} while (0)
++
++
++#define LINE(v0, v1)                            \
++do {                                            \
++        glamo_draw_line(gCtx, v0, v1);          \
++} while (0)
++
++
++#define POINT(v0)                               \
++do {                                            \
++        glamo_draw_point(gCtx, v0);             \
++} while (0)
++
++
++#define IND (0)
++#define TAG(x) x
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++
++static void init_rast_tab()
++{
++	init();
++	init_offset();
++	init_twoside();
++	init_twoside_offset();
++	init_unfilled();
++	init_offset_unfilled();
++	init_twoside_unfilled();
++	init_twoside_offset_unfilled();
++	init_fallback();
++	init_offset_fallback();
++	init_twoside_fallback();
++	init_twoside_offset_fallback();
++	init_unfilled_fallback();
++	init_offset_unfilled_fallback();
++	init_twoside_unfilled_fallback();
++	init_twoside_offset_unfilled_fallback();
++}
++
++
++void glamoInitTriFuncs(GLcontext *ctx)
++{
++	TNLcontext *tnl = TNL_CONTEXT(ctx);
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	static int firsttime = 1;
++
++	if (firsttime) {
++		init_rast_tab();
++		firsttime = 0;
++	}
++
++	gCtx->prim.start_offset = 0;
++	gCtx->prim.current_offset = 0;
++	gCtx->prim.vb_bo = NULL;
++	gCtx->prim.vb = NULL;
++	gCtx->prim.count = 0;
++
++	tnl->Driver.RunPipeline = glamoRunPipeline;
++	tnl->Driver.Render.Start = glamoRenderStart;
++	tnl->Driver.Render.Finish = glamoRenderFinish;
++	tnl->Driver.Render.PrimitiveNotify = glamoPrimitiveNotify;
++	tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
++	tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
++	tnl->Driver.Render.CopyPV = _tnl_copy_pv;
++	tnl->Driver.Render.Interp = _tnl_interp;
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.h b/src/mesa/drivers/dri/glamo/glamo_tris.h
+new file mode 100644
+index 0000000..ba8f997
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_tris.h
+@@ -0,0 +1,38 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_TRIS_H
++#define __GLAMO_TRIS_H
++
++#include "main/mtypes.h"
++
++#include "glamo_context.h"
++
++/* Amount of space reserved for vertex submission */
++#define GLAMO_VB_SIZE (32*1024)
++
++extern void glamoInitTriFuncs(GLcontext *ctx);
++extern uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx,
++                                   unsigned int count);
++
++#endif   /* __GLAMO_TRIS_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
+index 39148f3..8244ec3 100644
+--- a/src/mesa/drivers/dri/glamo/glamo_screen.c
++++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
+@@ -166,7 +166,7 @@ static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
+    gfb = CALLOC_STRUCT(glamo_framebuffer);
+    if ( !gfb ) return GL_FALSE;
+ 
+-   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
++   _mesa_initialize_window_framebuffer(&gfb->base, mesaVis);
+ 
+    /* we only support this one format at the moment */
+    rgbFormat = GL_RGB5;
diff --git a/recipes/mesa/mesa-dri-7.8/fix-progs-makefile.patch b/recipes/mesa/mesa-dri-7.8/fix-progs-makefile.patch
deleted file mode 100644
index 40e6a1b..0000000
--- a/recipes/mesa/mesa-dri-7.8/fix-progs-makefile.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
-From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Thu, 4 Mar 2010 14:16:27 +0100
-Subject: [PATCH] fix libs
-
----
- progs/demos/Makefile   |    2 +-
- progs/glsl/Makefile    |    2 +-
- progs/redbook/Makefile |    2 +-
- progs/samples/Makefile |    2 +-
- progs/xdemos/Makefile  |    2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index 5b1d2a0..121b862 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
- 	$(APP_LIB_DEPS)
- 
- PROGS = \
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 3b5a595..836c4ac 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -10,7 +10,7 @@ LIB_DEP = \
- 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
- 	-l$(GL_LIB) $(APP_LIB_DEPS)
- 
- # using : to avoid APP_CC pointing to CC loop
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index b41e488..95ed746 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = aaindex \
- 	aapoly \
-diff --git a/progs/samples/Makefile b/progs/samples/Makefile
-index 64fa47a..9f72c8b 100644
---- a/progs/samples/Makefile
-+++ b/progs/samples/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
-diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
-index f866a32..c0f4e06 100644
---- a/progs/xdemos/Makefile
-+++ b/progs/xdemos/Makefile
-@@ -11,7 +11,7 @@
- # Add X11 and pthread libs to satisfy GNU gold.
- APP_LIB_DEPS += -lX11 -lpthread
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = \
- 	corender \
--- 
-1.7.0
-
diff --git a/recipes/mesa/mesa-dri-7.8/glamo.patch b/recipes/mesa/mesa-dri-7.8/glamo.patch
deleted file mode 100644
index cc55c8b..0000000
--- a/recipes/mesa/mesa-dri-7.8/glamo.patch
+++ /dev/null
@@ -1,2373 +0,0 @@
-diff --git a/configure.ac b/configure.ac
-index 61487c3..c4952bf 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -125,6 +125,9 @@ dnl Add flags for gcc and g++
- if test "x$GCC" = xyes; then
-     CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
- 
-+    # Work around GCC bug #39501
-+    CFLAGS="$CFLAGS -fno-finite-math-only"
-+
-     # Enable -fvisibility=hidden if using a gcc that supports it
-     save_CFLAGS="$CFLAGS"
-     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
-@@ -138,6 +141,9 @@ fi
- if test "x$GXX" = xyes; then
-     CXXFLAGS="$CXXFLAGS -Wall"
- 
-+    # Work around GCC bug #39501
-+    CXXFLAGS="$CXXFLAGS -fno-finite-math-only"
-+
-     # Work around aliasing bugs - developers should comment this out
-     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
- fi
-diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile
-new file mode 100644
-index 0000000..e77193d
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/Makefile
-@@ -0,0 +1,22 @@
-+# src/mesa/drivers/dri/glamo/Makefile
-+
-+TOP = ../../../../..
-+include $(TOP)/configs/current
-+
-+LIBNAME = glamo_dri.so
-+
-+DRIVER_SOURCES = \
-+	glamo_screen.c glamo_context.c glamo_state.c glamo_fbo.c glamo_tris.c \
-+	glamo_cmdq.c glamo_render.c
-+
-+C_SOURCES = \
-+	$(COMMON_SOURCES) \
-+	$(DRIVER_SOURCES)
-+
-+ASM_SOURCES =
-+
-+DRI_LIB_DEPS += -ldrm_glamo
-+
-+include ../Makefile.template
-+
-+symlinks:
-diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.c b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
-new file mode 100644
-index 0000000..1334f8e
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
-@@ -0,0 +1,110 @@
-+/*
-+ * Command queue submission via DRM
-+ *
-+ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <drm.h>
-+#include <glamo_drm.h>
-+#include <glamo_bo.h>
-+
-+#include "glamo_context.h"
-+#include "glamo_cmdq.h"
-+
-+
-+/* Submit the prepared command sequence to the kernel */
-+void glamoDRMDispatch(glamoContext *gCtx)
-+{
-+	drm_glamo_cmd_burst_t burst;
-+	int r;
-+
-+	burst.base = gCtx->cmd_burst_base;
-+	burst.data = gCtx->cmdq_drm;
-+	burst.bufsz = gCtx->cmdq_drm_used * 2;	/* -> bytes */
-+	burst.nobjs = gCtx->cmdq_obj_used;
-+	burst.objs = gCtx->cmdq_objs;
-+	burst.obj_pos = gCtx->cmdq_obj_pos;
-+
-+	r = drmCommandWrite(gCtx->drm_fd, DRM_GLAMO_CMDBURST,
-+	                    &burst, sizeof(burst));
-+	if ( r != 0 ) {
-+		fprintf(stderr, "DRM_GLAMO_CMDBURST failed\n");
-+	}
-+
-+	/* Reset counts to zero for the next sequence */
-+	gCtx->cmdq_obj_used = 0;
-+	gCtx->cmdq_drm_used = 0;
-+}
-+
-+
-+void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len)
-+{
-+	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
-+		fprintf(stderr, "Burst command too large\n");
-+		return;
-+	}
-+
-+	/* Record command */
-+	if ( len == 2 ) {
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff;
-+	} else if ( len == 4 ) {
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0x0000ffff;
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff0000;
-+	} else {
-+		fprintf(stderr, "Wrong command length!\n");
-+	}
-+}
-+
-+
-+void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo)
-+{
-+	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
-+		fprintf(stderr, "Burst command too large\n");
-+		return;
-+	}
-+
-+	/* Record object position */
-+	gCtx->cmdq_objs[gCtx->cmdq_obj_used] = bo->handle;
-+	/* -> bytes */
-+	gCtx->cmdq_obj_pos[gCtx->cmdq_obj_used] = gCtx->cmdq_drm_used * 2;
-+	gCtx->cmdq_obj_used++;
-+
-+	/* Record command */
-+	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
-+	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
-+}
-+
-+
-+void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base)
-+{
-+	gCtx->cmd_burst_base = base;
-+}
-+
-+
-+void glamoInitCmdqCache(glamoContext *gCtx)
-+{
-+	gCtx->cmdq_objs = malloc(1024);
-+	gCtx->cmdq_obj_pos = malloc(1024);
-+	gCtx->cmdq_obj_used = 0;
-+	gCtx->cmdq_drm_used = 0;
-+	gCtx->cmdq_drm_size = 4 * 1024;
-+	gCtx->cmdq_drm = malloc(gCtx->cmdq_drm_size);
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.h b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
-new file mode 100644
-index 0000000..7420d7b
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
-@@ -0,0 +1,33 @@
-+/*
-+ * Command queue submission via DRM
-+ *
-+ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+
-+#include <stdint.h>
-+#include <glamo_bo.h>
-+
-+#include "glamo_context.h"
-+
-+
-+extern void glamoDRMDispatch(glamoContext *gCtx);
-+extern void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo);
-+extern void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len);
-+extern void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base);
-+extern void glamoInitCmdqCache(glamoContext *gCtx);
-diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
-new file mode 100644
-index 0000000..527654f
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_context.c
-@@ -0,0 +1,360 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_context.c (c) 2003 Eric Anholt
-+ *              and radeon_common_context.c
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "dri_util.h"
-+#include "drirenderbuffer.h"
-+#include "utils.h"
-+
-+#include "swrast/swrast.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "drivers/common/driverfuncs.h"
-+#include "vbo/vbo.h"
-+#include "tnl/tnl.h"
-+#include "tnl/t_pipeline.h"
-+#include "main/state.h"
-+
-+#include "glamo_context.h"
-+#include "glamo_screen.h"
-+#include "glamo_state.h"
-+#include "glamo_fbo.h"
-+#include "glamo_tris.h"
-+#include "glamo_render.h"
-+#include "glamo_cmdq.h"
-+
-+#include <glamo_bo.h>
-+#include <glamo_bo_gem.h>
-+#include <glamo_drm.h>
-+
-+
-+#define DRIVER_DATE  "20090913"
-+
-+
-+static inline struct glamo_renderbuffer *glamo_get_renderbuffer(
-+                                                      struct gl_framebuffer *fb,
-+                                                      int att_index)
-+{
-+	if ( att_index >= 0 ) {
-+		struct glamo_renderbuffer *gr;
-+		gr = glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer);
-+		return gr;
-+	} else {
-+		return NULL;
-+	}
-+}
-+
-+
-+static const GLubyte *glamoGetString(GLcontext *ctx, GLenum name)
-+{
-+	static char buffer[128];
-+
-+	switch (name) {
-+	case GL_VENDOR:
-+		return (GLubyte *)"Thomas White";
-+	case GL_RENDERER: {
-+		driGetRendererString(buffer, "Glamo", DRIVER_DATE, 0);
-+		return (GLubyte *) buffer;
-+	}
-+	default:
-+		return 0;
-+	}
-+}
-+
-+
-+/* Called when Mesa needs to know the size of the framebuffer */
-+static void glamoBufferSize(GLframebuffer *buffer,
-+                            GLuint *width, GLuint *height)
-+{
-+	GET_CURRENT_CONTEXT(ctx);
-+	glamoContextPtr glamo = GLAMO_CONTEXT(ctx);
-+
-+	*width = glamo->driDrawable->w;
-+	*height = glamo->driDrawable->h;
-+}
-+
-+
-+GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
-+                             __DRIcontext *driContextPriv,
-+                             void *sharedContextPrivate)
-+{
-+	GLcontext *ctx, *shareCtx;
-+	__DRIscreen *sPriv = driContextPriv->driScreenPriv;
-+	glamoContextPtr context;
-+	glamoScreenPtr glamoScreen;
-+	struct dd_function_table functions;
-+
-+	context = (glamoContextPtr)CALLOC(sizeof(*context));
-+	if ( context == NULL ) return GL_FALSE;
-+
-+	_mesa_init_driver_functions(&functions);
-+
-+	/* Allocate the Mesa context */
-+	if ( sharedContextPrivate )
-+		shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
-+	else
-+		shareCtx = NULL;
-+	context->glCtx = _mesa_create_context(glVisual, shareCtx,
-+		                        &functions, (void *)context);
-+	if ( context->glCtx == NULL ) {
-+		FREE(context);
-+		return GL_FALSE;
-+	}
-+	driContextPriv->driverPrivate = context;
-+	ctx = context->glCtx;
-+
-+	glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
-+
-+	ctx->Driver.GetString = glamoGetString;
-+	ctx->Driver.GetBufferSize = glamoBufferSize;
-+
-+	context->driContext = driContextPriv;
-+	context->driScreen = sPriv;
-+	context->driDrawable = NULL;
-+	context->drm_fd = sPriv->fd;
-+
-+	/* Initialize the software rasterizer and helper modules. */
-+	_swrast_CreateContext(ctx);
-+	_vbo_CreateContext(ctx);
-+	_tnl_CreateContext(ctx);
-+	_swsetup_CreateContext(ctx);
-+
-+	/* Install our pipeline (see glamo_render.c) */
-+	_tnl_install_pipeline(ctx, glamo_pipeline);
-+
-+	_swrast_allow_pixel_fog(ctx, GL_TRUE);
-+	_swrast_allow_vertex_fog(ctx, GL_FALSE);
-+	_tnl_allow_pixel_fog(ctx, GL_TRUE);
-+	_tnl_allow_vertex_fog(ctx, GL_FALSE);
-+
-+	glamoInitCmdqCache(context);
-+	glamoInitStateFuncs(ctx);
-+	glamoInitTriFuncs(ctx);
-+
-+	return GL_TRUE;
-+}
-+
-+
-+void glamoDestroyContext(__DRIcontext *driContextPriv)
-+{
-+	glamoContextPtr context;
-+
-+	context = (glamoContextPtr)driContextPriv->driverPrivate;
-+	assert(context != NULL);
-+
-+	if ( context != NULL ) {
-+
-+		_swsetup_DestroyContext(context->glCtx);
-+		_tnl_DestroyContext(context->glCtx);
-+		_vbo_DestroyContext(context->glCtx);
-+		_swrast_DestroyContext(context->glCtx);
-+
-+		_mesa_destroy_context(context->glCtx);
-+
-+	}
-+
-+	FREE(context);
-+}
-+
-+
-+void glamo_update_renderbuffers(__DRIcontext *context,
-+                                __DRIdrawable *drawable)
-+{
-+	unsigned int attachments[10];
-+	__DRIbuffer *buffers;
-+	__DRIscreen *screen;
-+	int i, count;
-+	struct glamo_framebuffer *draw;
-+	glamoContextPtr glamo;
-+	struct glamo_bo *bo;
-+
-+	draw = drawable->driverPrivate;
-+	screen = context->driScreenPriv;
-+	glamo = (glamoContextPtr)context->driverPrivate;
-+	i = 0;
-+	if ( draw->color_rb[0] ) {
-+		attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-+	}
-+	if ( draw->color_rb[1] ) {
-+		attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-+	}
-+
-+	buffers = screen->dri2.loader->getBuffers(drawable,
-+	                                          &drawable->w,
-+	                                          &drawable->h,
-+	                                          attachments, i,
-+	                                          &count,
-+	                                          drawable->loaderPrivate);
-+	if ( buffers == NULL ) return;
-+
-+	/* Set one cliprect to cover the whole drawable */
-+	drawable->x = 0;
-+	drawable->y = 0;
-+	drawable->backX = 0;
-+	drawable->backY = 0;
-+	drawable->numClipRects = 1;
-+	drawable->pClipRects[0].x1 = 0;
-+	drawable->pClipRects[0].y1 = 0;
-+	drawable->pClipRects[0].x2 = drawable->w;
-+	drawable->pClipRects[0].y2 = drawable->h;
-+	drawable->numBackClipRects = 1;
-+	drawable->pBackClipRects[0].x1 = 0;
-+	drawable->pBackClipRects[0].y1 = 0;
-+	drawable->pBackClipRects[0].x2 = drawable->w;
-+	drawable->pBackClipRects[0].y2 = drawable->h;
-+
-+	/* For each attachment */
-+	for ( i=0; i<count; i++ ) {
-+
-+		struct glamo_renderbuffer *grb;
-+
-+		switch ( buffers[i].attachment ) {
-+		case __DRI_BUFFER_FRONT_LEFT:
-+			grb = draw->color_rb[0];
-+			break;
-+		case __DRI_BUFFER_BACK_LEFT:
-+			grb = draw->color_rb[1];
-+			break;
-+		case __DRI_BUFFER_DEPTH:
-+			grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH);
-+			break;
-+		case __DRI_BUFFER_STENCIL:
-+			grb = glamo_get_renderbuffer(&draw->base,
-+			                                        BUFFER_STENCIL);
-+			break;
-+		case __DRI_BUFFER_FAKE_FRONT_LEFT:
-+			grb = draw->color_rb[0];
-+			break;
-+		case __DRI_BUFFER_ACCUM:
-+		default:
-+			fprintf(stderr,
-+				"Unhandled buffer attach event,"
-+				" attachment type %d\n", buffers[i].attachment);
-+			return;
-+		}
-+
-+		if ( grb == NULL ) {
-+			/* Don't know how to handle this type of buffer */
-+			continue;
-+		}
-+
-+		if ( grb->bo ) {
-+			uint32_t name = glamo_gem_get_name(grb->bo);
-+			if ( name == buffers[i].name ) {
-+				/* Buffer already attached.  No action needed */
-+				continue;
-+			}
-+		}
-+
-+		grb->cpp = buffers[i].cpp;
-+		grb->pitch = buffers[i].pitch;
-+		grb->width = drawable->w;
-+		grb->height = drawable->h;
-+
-+		bo = glamo_bo_open(glamo->glamoScreen->bom, buffers[i].name,
-+		                   0, 0, GLAMO_GEM_DOMAIN_VRAM,
-+		                   buffers[i].flags);
-+		if ( bo == NULL ) {
-+			fprintf(stderr, "Failed to attach buffer %d\n",
-+				buffers[i].name);
-+		}
-+
-+		glamo_renderbuffer_set_bo(grb, bo);
-+		glamo_bo_unref(bo);
-+
-+	}
-+
-+	driUpdateFramebufferSize(glamo->glCtx, drawable);
-+}
-+
-+
-+GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
-+                           __DRIdrawable *driDrawPriv,
-+                           __DRIdrawable *driReadPriv)
-+{
-+	struct glamo_framebuffer *draw_fb;
-+	struct gl_framebuffer *read_fb;
-+	glamoContextPtr glamo;
-+
-+	if ( driContextPriv == NULL ) {
-+		_mesa_make_current(NULL, NULL, NULL);
-+		return GL_TRUE;
-+	}
-+
-+	/* The Glamo context we're switching to */
-+	glamo = (glamoContextPtr)driContextPriv->driverPrivate;
-+
-+	glamo->driDrawable = driDrawPriv;
-+
-+	/* These two will probably be the same */
-+	draw_fb = (struct glamo_framebuffer *)driDrawPriv->driverPrivate;
-+	read_fb = (struct gl_framebuffer *)driReadPriv->driverPrivate;
-+
-+	glamo_update_renderbuffers(driContextPriv, driDrawPriv);
-+	if (driDrawPriv != driReadPriv)
-+		glamo_update_renderbuffers(driContextPriv, driReadPriv);
-+
-+	_mesa_make_current(glamo->glCtx, &draw_fb->base, read_fb);
-+	_mesa_update_state(glamo->glCtx);
-+
-+	return GL_TRUE;
-+}
-+
-+
-+GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
-+{
-+	return GL_TRUE;
-+}
-+
-+
-+/* Convert IEEE754 32-bit float to Glamo's signed 24-bit float */
-+uint32_t float7s16(GLfloat in)
-+{
-+	uint32_t a, b;
-+	uint32_t sign, expo, mant;  /* Sign, exponent, significand */
-+
-+	a = *(uint32_t *)&in;
-+
-+	/* This is bad */
-+	if ( a & 0x40000000 ) {
-+		printf(stderr, "Warning: Exponent won't fit into 7 bits\n");
-+	}
-+
-+	/* This hopefully isn't a big problem */
-+	if ( a & 0x0000007f ) {
-+		printf(stderr, "Warning: Precision lost in FP conversion\n");
-+	}
-+
-+	/* Separate out the right bits */
-+	mant = a & 0x007fff80;  /* Bits 7-22 (bits 0-6 are lost) */
-+	expo = a & 0x3f800000;  /* Bits 23-29 (bit 30 is lost) */
-+	sign = a & 0x80000000;  /* Bit 31 */
-+
-+	/* Shift and recombine */
-+	b  = sign >> 8;  /* Fills bit 23 */
-+	b |= expo >> 7;  /* Fills bits 16-22 */
-+	b |= mant >> 7;  /* Fills bits 0-15 */
-+
-+	return b;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
-new file mode 100644
-index 0000000..ccce29c
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_context.h
-@@ -0,0 +1,106 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_context.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_CONTEXT_H
-+#define __GLAMO_CONTEXT_H
-+
-+
-+#include "dri_util.h"
-+#include "utils.h"
-+#include "tnl/t_vertex.h"
-+
-+#include "glamo_screen.h"
-+
-+
-+typedef struct glamo_context glamoContext;
-+typedef struct glamo_context *glamoContextPtr;
-+
-+struct glamo_context {
-+
-+	GLcontext *glCtx;                  /* Must be first in this structure */
-+
-+	int drm_fd;                        /* DRM fd */
-+
-+	__DRIcontext  *driContext;  /* DRI context */
-+	__DRIscreen   *driScreen;   /* DRI screen */
-+	__DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */
-+
-+	glamoScreenPtr glamoScreen;        /* Screen private DRI data */
-+
-+	driOptionCache optionCache;
-+
-+	uint16_t *cmdq_drm;                /* Command queue cache */
-+	uint16_t cmd_burst_base;
-+	int cmdq_drm_used;
-+	int cmdq_drm_size;
-+	int cmdq_obj_used;
-+	uint32_t *cmdq_objs;
-+	unsigned int *cmdq_obj_pos;
-+
-+	/* Information about the current primitive */
-+	struct {
-+		GLuint id;
-+		uint32_t primitive;	/* Current hardware primitive type */
-+		struct glamo_bo *vb_bo;
-+		uint8_t *vb;
-+		unsigned int start_offset; /* Byte offset of start */
-+		unsigned int current_offset; /* Byte offset of next vertex */
-+		unsigned int count;	/* Number of vertices */
-+	} prim;
-+
-+	/* Current vertex format and attributes */
-+	int vertex_size;
-+	struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
-+
-+	/* State */
-+	GLuint new_state;      /* State which must be updated */
-+	uint16_t col_clear;
-+
-+};
-+
-+#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
-+
-+#define TAG(x) glamo##x
-+#include "tnl_dd/t_dd_vertex.h"
-+#undef TAG
-+
-+extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
-+                                    __DRIcontext *driContextPriv,
-+                                    void *sharedContextPrivate);
-+extern void glamoDestroyContext(__DRIcontext *dcp);
-+extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
-+                                  __DRIdrawable *driDrawPriv,
-+                                  __DRIdrawable *driReadPriv);
-+extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
-+extern void glamo_update_renderbuffers(__DRIcontext *context,
-+                                       __DRIdrawable *drawable);
-+
-+#define GLAMO_PACKCOLOR565(r, g, b) \
-+	((((r) & 0xf8) << 8)        \
-+	| (((g) & 0xfc) << 3)       \
-+	| (((b) & 0xf8) >> 3))
-+
-+extern uint32_t float7s16(GLfloat in);
-+
-+#endif   /* __GLAMO_CONTEXT_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c
-new file mode 100644
-index 0000000..c866d21
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c
-@@ -0,0 +1,130 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on radeon_fbo.c (c) 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"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "main/imports.h"
-+#include "main/macros.h"
-+#include "main/mtypes.h"
-+#include "main/formats.h"
-+#include "main/fbobject.h"
-+#include "main/framebuffer.h"
-+#include "main/renderbuffer.h"
-+#include "main/context.h"
-+#include "dri_util.h"
-+
-+/* This comes from libdrm_glamo */
-+#include <glamo_bo.h>
-+
-+#include "glamo_fbo.h"
-+
-+
-+static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb)
-+{
-+   struct glamo_renderbuffer *grb = glamo_renderbuffer(rb);
-+
-+   ASSERT(grb);
-+
-+   if ( grb && grb->bo ) {
-+      glamo_bo_unref(grb->bo);
-+   }
-+   _mesa_free(grb);
-+}
-+
-+
-+static void *glamo_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb,
-+                               GLint x, GLint y)
-+{
-+   return NULL;   /* Can't be directly addressed */
-+}
-+
-+
-+/* Called for each hardware renderbuffer when a _window_ is resized.
-+ * Just update fields.
-+ * Not used for user-created renderbuffers!
-+ */
-+static GLboolean glamo_alloc_window_storage(GLcontext *ctx,
-+                                            struct gl_renderbuffer *rb,
-+                                            GLenum internalFormat,
-+                                            GLuint width, GLuint height)
-+{
-+   ASSERT(rb->Name == 0);
-+   rb->Width = width;
-+   rb->Height = height;
-+   rb->Format = internalFormat;
-+   return GL_TRUE;
-+}
-+
-+
-+/* Create a buffer, such as a colour or depth buffer */
-+struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
-+                                              __DRIdrawable *driDrawPriv)
-+{
-+   struct glamo_renderbuffer *grb;
-+
-+   grb = CALLOC_STRUCT(glamo_renderbuffer);
-+   if ( !grb ) return NULL;
-+
-+   _mesa_init_renderbuffer(&grb->base, 0);
-+   grb->base.ClassID = GLAMO_RB_CLASS;
-+
-+   switch (format) {
-+      case GL_RGB5:
-+         grb->base.Format = MESA_FORMAT_RGB565;
-+         grb->base._BaseFormat = GL_RGB;
-+
-+         grb->base.DataType = GL_UNSIGNED_BYTE;
-+         break;
-+      case GL_DEPTH_COMPONENT16:
-+         grb->base.DataType = GL_UNSIGNED_SHORT;
-+	 grb->base._BaseFormat = GL_DEPTH_COMPONENT;
-+         break;
-+      default:
-+         fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
-+         _mesa_delete_renderbuffer(&grb->base);
-+         return NULL;
-+   }
-+
-+   grb->dPriv = driDrawPriv;
-+   grb->base.InternalFormat = format;
-+
-+   grb->base.Delete = glamo_delete_renderbuffer;
-+   grb->base.AllocStorage = glamo_alloc_window_storage;
-+   grb->base.GetPointer = glamo_get_pointer;
-+
-+   return grb;
-+}
-+
-+
-+void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
-+                               struct glamo_bo *bo)
-+{
-+  struct glamo_bo *old;
-+  old = grb->bo;
-+  grb->bo = bo;
-+  glamo_bo_ref(bo);
-+  if ( old ) glamo_bo_unref(old);
-+}
-+
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h
-new file mode 100644
-index 0000000..48210dd
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h
-@@ -0,0 +1,77 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_FBO_H
-+#define __GLAMO_FBO_H
-+
-+
-+#include "main/mtypes.h"
-+#include "dri_util.h"
-+
-+
-+/* This is just a marker so we can tell a Glamo renderbuffer from a Mesa one */
-+#define GLAMO_RB_CLASS (0xdeadbeef)
-+
-+
-+struct glamo_renderbuffer
-+{
-+	struct gl_renderbuffer base;   /* Must be first */
-+	struct glamo_bo *bo;
-+	unsigned int cpp;
-+	unsigned int pitch;
-+	unsigned int width;
-+	unsigned int height;
-+
-+	__DRIdrawable *dPriv;
-+};
-+
-+
-+struct glamo_framebuffer
-+{
-+	struct gl_framebuffer base;
-+	struct glamo_renderbuffer *color_rb[2];
-+};
-+
-+
-+/* This is just a small wrapper function to return NULL if the gl_renderbuffer
-+ * is not a glamo_renderbuffer */
-+static inline struct glamo_renderbuffer
-+                                 *glamo_renderbuffer(struct gl_renderbuffer *rb)
-+{
-+	struct glamo_renderbuffer *grb = (struct glamo_renderbuffer *)rb;
-+	if ( grb && grb->base.ClassID == GLAMO_RB_CLASS )
-+		return grb;
-+	else
-+		return NULL;
-+}
-+
-+
-+extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
-+                                             __DRIdrawable *driDrawPriv);
-+
-+extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
-+                               struct glamo_bo *bo);
-+
-+#endif   /* __GLAMO_FBO_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_regs.h b/src/mesa/drivers/dri/glamo/glamo_regs.h
-new file mode 100644
-index 0000000..02b2294
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_regs.h
-@@ -0,0 +1,174 @@
-+#ifndef _GLAMO_REGS_H
-+#define _GLAMO_REGS_H
-+
-+/* Smedia Glamo 336x/337x driver
-+ *
-+ * (C) 2007 by OpenMoko, Inc.
-+ * Author: Harald Welte <laforge@openmoko.org>
-+ * All rights reserved.
-+ *
-+ * Modified for Glamo Mesa driver by Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+enum glamo_regster_offsets {
-+	GLAMO_REGOFS_GENERIC	= 0x0000,
-+	GLAMO_REGOFS_HOSTBUS	= 0x0200,
-+	GLAMO_REGOFS_MEMORY	= 0x0300,
-+	GLAMO_REGOFS_VIDCAP	= 0x0400,
-+	GLAMO_REGOFS_ISP	= 0x0500,
-+	GLAMO_REGOFS_JPEG	= 0x0800,
-+	GLAMO_REGOFS_MPEG	= 0x0c00,
-+	GLAMO_REGOFS_LCD	= 0x1100,
-+	GLAMO_REGOFS_MMC	= 0x1400,
-+	GLAMO_REGOFS_MPROC0	= 0x1500,
-+	GLAMO_REGOFS_MPROC1	= 0x1580,
-+	GLAMO_REGOFS_CMDQUEUE	= 0x1600,
-+	GLAMO_REGOFS_RISC	= 0x1680,
-+	GLAMO_REGOFS_2D		= 0x1700,
-+	GLAMO_REGOFS_3D		= 0x1b00,
-+};
-+
-+
-+#define REG_MPEG(x)           (GLAMO_REGOFS_MPEG+(x))
-+
-+enum glamo_register_mpeg {
-+      //
-+      GLAMO_REG_MPEG_DC_ADDRL         = REG_MPEG(0x3c),
-+      GLAMO_REG_MPEG_DC_ADDRH         = REG_MPEG(0x3e),
-+      GLAMO_REG_MPEG_AC_ADDRL         = REG_MPEG(0x40),
-+      GLAMO_REG_MPEG_AC_ADDRH         = REG_MPEG(0x42),
-+      //
-+      GLAMO_REG_MPEG_SAFE_1           = REG_MPEG(0x60),
-+      GLAMO_REG_MPEG_SAFE_2           = REG_MPEG(0x62),
-+      GLAMO_REG_MPEG_SAFE_3           = REG_MPEG(0x64),
-+      //
-+      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRL = REG_MPEG(0x6e),
-+      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRH = REG_MPEG(0x70),
-+      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRL = REG_MPEG(0x72),
-+      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRH = REG_MPEG(0x74),
-+      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRL = REG_MPEG(0x76),
-+      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRH = REG_MPEG(0x78),
-+      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRL = REG_MPEG(0x7a),
-+      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRH = REG_MPEG(0x7c),
-+      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRL = REG_MPEG(0x7e),
-+      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRH = REG_MPEG(0x80),
-+      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRL = REG_MPEG(0x82),
-+      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRH = REG_MPEG(0x84),
-+      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRL = REG_MPEG(0x86),
-+      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRH = REG_MPEG(0x88),
-+      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRL = REG_MPEG(0x8a),
-+      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRH = REG_MPEG(0x8c),
-+      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRL = REG_MPEG(0x8e),
-+      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRH = REG_MPEG(0x90),
-+      GLAMO_REG_MPEG_DEC_WIDTH        = REG_MPEG(0x92),
-+      GLAMO_REG_MPEG_DEC_HEIGHT       = REG_MPEG(0x94),
-+      GLAMO_REG_MPEG_SPECIAL          = REG_MPEG(0x96),
-+      GLAMO_REG_MPEG_DEC_IN_ADDRL     = REG_MPEG(0x98),
-+      GLAMO_REG_MPEG_DEC_IN_ADDRH     = REG_MPEG(0x9a),
-+      //
-+      GLAMO_REG_MPEG_DEBLK_THRESHOLD  = REG_MPEG(0xc0),
-+      //
-+      GLAMO_REG_MPEG_DEC_STATUS       = REG_MPEG(0xc8),
-+      GLAMO_REG_MPEG_DEC_RB0          = REG_MPEG(0xca),
-+      GLAMO_REG_MPEG_DEC_RB1          = REG_MPEG(0xcc),
-+};
-+
-+
-+#define REG_2D(x)		(GLAMO_REGOFS_2D+(x))
-+
-+enum glamo_register_2d {
-+	GLAMO_REG_2D_SRC_ADDRL		= REG_2D(0x00),
-+	GLAMO_REG_2D_SRC_ADDRH		= REG_2D(0x02),
-+	GLAMO_REG_2D_SRC_PITCH		= REG_2D(0x04),
-+	GLAMO_REG_2D_SRC_X		= REG_2D(0x06),
-+	GLAMO_REG_2D_SRC_Y		= REG_2D(0x08),
-+	GLAMO_REG_2D_DST_X		= REG_2D(0x0a),
-+	GLAMO_REG_2D_DST_Y		= REG_2D(0x0c),
-+	GLAMO_REG_2D_DST_ADDRL		= REG_2D(0x0e),
-+	GLAMO_REG_2D_DST_ADDRH		= REG_2D(0x10),
-+	GLAMO_REG_2D_DST_PITCH		= REG_2D(0x12),
-+	GLAMO_REG_2D_DST_HEIGHT		= REG_2D(0x14),
-+	GLAMO_REG_2D_RECT_WIDTH		= REG_2D(0x16),
-+	GLAMO_REG_2D_RECT_HEIGHT	= REG_2D(0x18),
-+	GLAMO_REG_2D_PAT_ADDRL		= REG_2D(0x1a),
-+	GLAMO_REG_2D_PAT_ADDRH		= REG_2D(0x1c),
-+	GLAMO_REG_2D_PAT_FG		= REG_2D(0x1e),
-+	GLAMO_REG_2D_PAT_BG		= REG_2D(0x20),
-+	GLAMO_REG_2D_SRC_FG		= REG_2D(0x22),
-+	GLAMO_REG_2D_SRC_BG		= REG_2D(0x24),
-+	GLAMO_REG_2D_MASK1		= REG_2D(0x26),
-+	GLAMO_REG_2D_MASK2		= REG_2D(0x28),
-+	GLAMO_REG_2D_MASK3		= REG_2D(0x2a),
-+	GLAMO_REG_2D_MASK4		= REG_2D(0x2c),
-+	GLAMO_REG_2D_ROT_X		= REG_2D(0x2e),
-+	GLAMO_REG_2D_ROT_Y		= REG_2D(0x30),
-+	GLAMO_REG_2D_LEFT_CLIP		= REG_2D(0x32),
-+	GLAMO_REG_2D_TOP_CLIP		= REG_2D(0x34),
-+	GLAMO_REG_2D_RIGHT_CLIP		= REG_2D(0x36),
-+	GLAMO_REG_2D_BOTTOM_CLIP	= REG_2D(0x38),
-+	GLAMO_REG_2D_COMMAND1		= REG_2D(0x3A),
-+	GLAMO_REG_2D_COMMAND2		= REG_2D(0x3C),
-+	GLAMO_REG_2D_COMMAND3		= REG_2D(0x3E),
-+	GLAMO_REG_2D_SAFE		= REG_2D(0x40),
-+	GLAMO_REG_2D_STATUS		= REG_2D(0x42),
-+	GLAMO_REG_2D_ID1		= REG_2D(0x44),
-+	GLAMO_REG_2D_ID2		= REG_2D(0x46),
-+	GLAMO_REG_2D_ID3		= REG_2D(0x48),
-+};
-+
-+
-+/* No offset this time */
-+#define REG_3D(x)		(x)
-+
-+enum glamo_register_3d
-+{
-+	/* Fire the engine */
-+	G3D_FIRE			= REG_3D(0x2058),
-+
-+	/* Streams of vertex/colour/normal/texcoord data */
-+	G3D_ACTIVE_STREAMS		= REG_3D(0x1f00),
-+	G3D_LAST_STREAM__VCOLFMT	= REG_3D(0x2030),
-+	G3D_STREAM_MODE_0		= REG_3D(0x1f10),
-+	G3D_STREAM_BASE_0		= REG_3D(0x1f14),
-+	G3D_STREAM_MODE_1		= REG_3D(0x1f18),
-+	G3D_STREAM_BASE_1		= REG_3D(0x1f1c),
-+	G3D_STREAM_MODE_2		= REG_3D(0x1f20),
-+	G3D_STREAM_BASE_2		= REG_3D(0x1f24),
-+	G3D_STREAM_MODE_3		= REG_3D(0x1f28),
-+	G3D_STREAM_BASE_3		= REG_3D(0x1f2c),
-+	G3D_STREAM_MODE_4		= REG_3D(0x1f30),
-+	G3D_STREAM_BASE_4		= REG_3D(0x1f34),
-+	G3D_STREAM_MODE_5		= REG_3D(0x1f38),
-+	G3D_STREAM_BASE_5		= REG_3D(0x1f3c),
-+	G3D_STREAM_MODE_6		= REG_3D(0x1f40),
-+	G3D_STREAM_BASE_6		= REG_3D(0x1f44),
-+	G3D_STREAM_MODE_7		= REG_3D(0x1f48),
-+	G3D_STREAM_BASE_7		= REG_3D(0x1f4c),
-+
-+	/* Modelview*projection matrix */
-+	G3D_MATRIX_MVP			= REG_3D(0x26a0), /* .. 0x27df */
-+
-+	/* Modelview matrix */
-+	G3D_MATRIX_MV			= REG_3D(0x26e0), /* .. 0x270f */
-+
-+	/* Inverse MVP, 3x3 only */
-+	G3D_MATRIX_IMVP			= REG_3D(0x2710), /* .. 0x2733 */
-+
-+};
-+
-+#endif /* _GLAMO_REGS_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c
-new file mode 100644
-index 0000000..fd52418
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_render.c
-@@ -0,0 +1,230 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Based on intel_render.c, to which the following notice applies:
-+ *
-+ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS 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.
-+ *
-+ */
-+
-+
-+/*
-+ * Render unclipped vertex buffers by emitting vertices directly to
-+ * dma buffers.  Use strip/fan hardware acceleration where possible.
-+ *
-+ */
-+#include "main/glheader.h"
-+#include "main/context.h"
-+#include "main/macros.h"
-+#include "main/imports.h"
-+#include "main/mtypes.h"
-+#include "main/enums.h"
-+
-+#include "tnl/t_context.h"
-+#include "tnl/t_vertex.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "glamo_context.h"
-+#include "glamo_tris.h"
-+#include "glamo_regs.h"
-+
-+/*
-+ * Render unclipped vertex buffers by emitting vertices directly to
-+ * VRAM buffers.  Use strip/fan hardware primitives where possible.
-+ * Try to simulate missing primitives with indexed vertices.
-+ */
-+#define HAVE_POINTS      1
-+#define HAVE_LINES       1
-+#define HAVE_LINE_STRIPS 0
-+#define HAVE_TRIANGLES   1
-+#define HAVE_TRI_STRIPS  0
-+#define HAVE_TRI_STRIP_1 0
-+#define HAVE_TRI_FANS    0
-+#define HAVE_POLYGONS    0
-+#define HAVE_QUADS       0
-+#define HAVE_QUAD_STRIPS 0
-+#define HAVE_ELTS        0
-+
-+
-+static void glamoFlushPrim(struct glamo_context *gCtx)
-+{
-+	printf("glamoFlushPrim: %i vertices, %i %i\n", gCtx->prim.count,
-+	gCtx->prim.start_offset, gCtx->prim.current_offset);
-+
-+	if ( gCtx->prim.vb_bo == NULL ) return;
-+
-+	/* Upload to hardware */
-+	glamo_bo_subdata(gCtx->prim.vb_bo, 0, gCtx->prim.current_offset,
-+	                 gCtx->prim.vb);
-+
-+	/* Dispatch to the hardware */
-+	glamoDRMStartBurst(gCtx, G3D_STREAM_MODE_0);
-+	glamoDRMAddData(gCtx, 0x000f0300, 4);
-+	glamoDRMAddBO(gCtx, gCtx->prim.vb_bo);
-+	glamoDRMDispatch(gCtx);
-+
-+	/* Please use a new BO for the next buffer */
-+	gCtx->prim.vb_bo = NULL;
-+
-+	/* Continue from new start */
-+	gCtx->prim.start_offset = gCtx->prim.current_offset;
-+}
-+
-+
-+static inline GLuint glamoGetVBMax(struct glamo_context *gCtx)
-+{
-+	return GLAMO_VB_SIZE / gCtx->vertex_size;
-+}
-+
-+
-+static inline GLuint glamoGetCurrentMax(struct glamo_context *gCtx)
-+{
-+	/* How many more vertices can be accommodated?
-+	 * Each vertex takes up 4x 32-bit fixed point values */
-+	return (GLAMO_VB_SIZE - gCtx->prim.current_offset) / gCtx->vertex_size;
-+}
-+
-+
-+#define LOCAL_VARS \
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+#define INIT(prim)
-+
-+#define FLUSH() glamoFlushPrim(gCtx)
-+
-+#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx)
-+#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx)
-+
-+#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr)
-+
-+#define EMIT_VERTS(ctx, j, nr, buf) \
-+	_tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
-+
-+#define TAG(x) glamo_##x
-+#include "tnl_dd/t_dd_dmatmp.h"
-+
-+
-+/**********************************************************************/
-+/*                          Render pipeline stage                     */
-+/**********************************************************************/
-+
-+static void glamoFireEngine(struct glamo_context *gCtx)
-+{
-+	glamoDRMStartBurst(gCtx, G3D_FIRE);
-+	glamoDRMAddData(gCtx, 0, 2);  /* Fire! */
-+	glamoDRMDispatch(gCtx);
-+}
-+
-+
-+static GLboolean glamoRunRender(GLcontext *ctx,
-+                                struct tnl_pipeline_stage *stage)
-+{
-+	TNLcontext *tnl = TNL_CONTEXT(ctx);
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	struct vertex_buffer *VB = &tnl->vb;
-+	GLuint i;
-+
-+	printf("glamoRunRender\n");
-+
-+	/* Don't handle clipping */
-+	if ( !glamo_validate_render(ctx, VB) ) {
-+		return GL_TRUE; /* Failed */
-+	}
-+
-+	/* Validate GPU state */
-+	if ( gCtx->new_state ) {
-+		if ( !glamoValidateState(ctx, gCtx->new_state) ) {
-+			printf("Couldn't validate state...\n");
-+		}
-+	} /* else nothing to update */
-+
-+	tnl->clipspace.new_inputs |= VERT_BIT_POS;
-+
-+	tnl->Driver.Render.Start(ctx);
-+
-+	for ( i=0; i<VB->PrimitiveCount; i++ ) {
-+
-+		GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
-+		GLuint start = VB->Primitive[i].start;
-+		GLuint length = VB->Primitive[i].count;
-+
-+		if (!length) continue;
-+
-+		glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start,
-+                                                     start + length, prim);
-+
-+	}
-+
-+	tnl->Driver.Render.Finish(ctx);
-+
-+	glamoFireEngine(gCtx);
-+
-+	return GL_FALSE;  /* Ok */
-+}
-+
-+
-+static const struct tnl_pipeline_stage _glamo_render_stage = {
-+	"glamo render",
-+	NULL,
-+	NULL,
-+	NULL,
-+	NULL,
-+	glamoRunRender
-+};
-+
-+
-+const struct tnl_pipeline_stage *glamo_pipeline[] = {
-+	&_tnl_vertex_transform_stage,
-+	&_tnl_vertex_cull_stage,
-+	&_tnl_normal_transform_stage,
-+	&_tnl_lighting_stage,
-+	&_tnl_fog_coordinate_stage,
-+	&_tnl_texgen_stage,
-+	&_tnl_texture_transform_stage,
-+	&_tnl_point_attenuation_stage,
-+	&_tnl_vertex_program_stage,
-+	&_glamo_render_stage,        /* ADD: unclipped rastersetup-to-dma */
-+	&_tnl_render_stage,
-+	0,
-+};
-diff --git a/src/mesa/drivers/dri/glamo/glamo_render.h b/src/mesa/drivers/dri/glamo/glamo_render.h
-new file mode 100644
-index 0000000..99c36a8
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_render.h
-@@ -0,0 +1,31 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_RENDER_H
-+#define __GLAMO_RENDER_H
-+
-+#include "main/mtypes.h"
-+
-+extern const struct tnl_pipeline_stage *glamo_pipeline[];
-+
-+#endif   /* __GLAMO_RENDER_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
-new file mode 100644
-index 0000000..39148f3
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
-@@ -0,0 +1,250 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_screen.c (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "dri_util.h"
-+#include "utils.h"
-+#include "xmlconfig.h"
-+#include "GL/internal/dri_interface.h"
-+#include "main/framebuffer.h"
-+#include "main/renderbuffer.h"
-+
-+#include "glamo_screen.h"
-+#include "glamo_context.h"
-+#include "glamo_fbo.h"
-+
-+/* This comes from libdrm_glamo */
-+#include <glamo_bo_gem.h>
-+
-+
-+static int glamoInitDriver(__DRIscreen *psp)
-+{
-+   return 0;
-+}
-+
-+
-+static glamoScreenPtr glamoCreateScreen(__DRIscreen *sPriv)
-+{
-+   glamoScreenPtr glamoScreen;
-+
-+   /* Allocate the private area */
-+   glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen));
-+   if ( glamoScreen == NULL )
-+      return NULL;
-+
-+   glamoScreen->driScreen = sPriv;
-+
-+   /* This is our link to the kernel's memory manager, via libdrm */
-+   glamoScreen->bom = glamo_bo_manager_gem_ctor(sPriv->fd);
-+
-+   return glamoScreen;
-+}
-+
-+
-+static void glamoDestroyScreen(__DRIscreen *sPriv)
-+{
-+   glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private;
-+
-+   if ( glamoScreen == NULL )
-+      return;
-+
-+   FREE(glamoScreen);
-+   sPriv->private = NULL;
-+}
-+
-+
-+static const __DRIconfig **glamoInitScreen(__DRIscreen *sPriv)
-+{
-+   __DRIconfig **configs;
-+   uint8_t depth_bits_array[2];
-+   uint8_t stencil_bits_array[2];
-+   uint8_t msaa_samples_array[1];
-+   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
-+
-+   /* Driver initialisation */
-+   if ( glamoInitDriver(sPriv) ) {
-+      return NULL;
-+   }
-+
-+   /* Screen-specific initialisation */
-+   sPriv->private = glamoCreateScreen(sPriv);
-+   if ( !sPriv->private ) {
-+      glamoDestroyScreen(sPriv);
-+      return NULL;
-+   }
-+
-+   depth_bits_array[0] = 0;
-+   stencil_bits_array[0] = 0;
-+   depth_bits_array[1] = 16;
-+   stencil_bits_array[1] = 0;
-+   msaa_samples_array[0] = 0;
-+
-+   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-+                           depth_bits_array, stencil_bits_array, 2,
-+                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
-+
-+   if ( configs == NULL ) {
-+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
-+      return NULL;
-+   }
-+
-+   return (const __DRIconfig **)configs;
-+}
-+
-+
-+static const __DRIconfig **glamoInitScreen2(__DRIscreen *sPriv)
-+{
-+   __DRIconfig **configs;
-+   uint8_t depth_bits_array[2];
-+   uint8_t stencil_bits_array[2];
-+   uint8_t msaa_samples_array[1];
-+   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
-+
-+   /* Driver initialisation */
-+   if ( glamoInitDriver(sPriv) ) {
-+      return NULL;
-+   }
-+
-+   /* Screen-specific initialisation */
-+   sPriv->private = glamoCreateScreen(sPriv);
-+   if ( !sPriv->private ) {
-+      glamoDestroyScreen(sPriv);
-+      return NULL;
-+   }
-+
-+   depth_bits_array[0] = 0;
-+   stencil_bits_array[0] = 0;
-+   depth_bits_array[1] = 16;
-+   stencil_bits_array[1] = 0;
-+   msaa_samples_array[0] = 0;
-+
-+   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-+                           depth_bits_array, stencil_bits_array, 2,
-+                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
-+
-+   if ( configs == NULL ) {
-+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
-+      return NULL;
-+   }
-+
-+   return (const __DRIconfig **)configs;
-+}
-+
-+
-+/* Allocate buffers for a context.  This is where the fun starts... */
-+static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
-+                                   __DRIdrawable *driDrawPriv,
-+                                   const __GLcontextModes *mesaVis,
-+                                   GLboolean isPixmap)
-+{
-+   struct glamo_framebuffer *gfb;
-+   GLenum rgbFormat;
-+
-+   if ( isPixmap ) return GL_FALSE; /* not implemented */
-+
-+   gfb = CALLOC_STRUCT(glamo_framebuffer);
-+   if ( !gfb ) return GL_FALSE;
-+
-+   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
-+
-+   /* we only support this one format at the moment */
-+   rgbFormat = GL_RGB5;
-+
-+   /* Front color renderbuffer */
-+   gfb->color_rb[0] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
-+   _mesa_add_renderbuffer(&gfb->base, BUFFER_FRONT_LEFT,
-+                          &gfb->color_rb[0]->base);
-+
-+   /* Back color renderbuffer, if requested */
-+   if ( mesaVis->doubleBufferMode ) {
-+      gfb->color_rb[1] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
-+      _mesa_add_renderbuffer(&gfb->base, BUFFER_BACK_LEFT,
-+                             &gfb->color_rb[1]->base);
-+   }
-+
-+   if ( mesaVis->depthBits == 16 ) {
-+      struct glamo_renderbuffer *depth;
-+      depth = glamo_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
-+      _mesa_add_renderbuffer(&gfb->base, BUFFER_DEPTH, &depth->base);
-+   }
-+
-+   /* Add software renderbuffers for the things we can't support in hardware */
-+   _mesa_add_soft_renderbuffers(&gfb->base,
-+      GL_FALSE,  /* color */
-+      GL_FALSE,  /* depth */
-+      mesaVis->stencilBits > 0,   /* stencil, if required */
-+      mesaVis->accumRedBits > 0,  /* accum, if required */
-+      GL_FALSE,  /* alpha */
-+      GL_FALSE   /* aux */
-+   );
-+   driDrawPriv->driverPrivate = (void *)gfb;
-+
-+   return (driDrawPriv->driverPrivate != NULL);
-+}
-+
-+
-+static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
-+{
-+}
-+
-+
-+static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
-+{
-+   printf("glamoSwapBuffers\n"); fflush(stdout);
-+}
-+
-+
-+/*
-+ *  Mesa entry points
-+ *
-+ *  See src/mesa/drivers/dri/common/dri_util.h for information about these
-+ */
-+const struct __DriverAPIRec driDriverAPI = {
-+   .InitScreen      = glamoInitScreen,
-+   .DestroyScreen   = glamoDestroyScreen,
-+   .CreateContext   = glamoCreateContext,
-+   .DestroyContext  = glamoDestroyContext,
-+   .CreateBuffer    = glamoCreateBuffer,
-+   .DestroyBuffer   = glamoDestroyBuffer,
-+   .SwapBuffers     = glamoSwapBuffers,
-+   .MakeCurrent     = glamoMakeCurrent,
-+   .UnbindContext   = glamoUnbindContext,
-+   .GetSwapInfo     = NULL,   /* Not used */
-+   .WaitForMSC      = NULL,
-+   .WaitForSBC      = NULL,
-+   .SwapBuffersMSC  = NULL,
-+   .CopySubBuffer   = NULL,
-+   .GetDrawableMSC  = NULL,   /* Not used */
-+   .InitScreen2     = glamoInitScreen2,    /* For DRI2 */
-+};
-+
-+/* This is the table of extensions that the loader will dlsym() for. */
-+PUBLIC const __DRIextension *__driDriverExtensions[] = {
-+    &driCoreExtension.base,
-+    &driLegacyExtension.base,
-+    &driDRI2Extension.base,
-+    NULL
-+};
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h
-new file mode 100644
-index 0000000..3f2eb5f
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.h
-@@ -0,0 +1,44 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_screen.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_SCREEN_H
-+#define __GLAMO_SCREEN_H
-+
-+#include "xmlconfig.h"
-+#include "dri_util.h"
-+
-+#include <glamo_bo_gem.h>
-+
-+typedef struct {
-+
-+   __DRIscreen *driScreen;
-+   driOptionCache optionCache;
-+
-+   struct glamo_bo_manager *bom;
-+
-+} glamoScreenRec, *glamoScreenPtr;
-+
-+#endif   /* __GLAMO_SCREEN_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c
-new file mode 100644
-index 0000000..4046c24
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_state.c
-@@ -0,0 +1,304 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009-2010 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_state.c (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Also partially based on intel_fbo.c, to which the following notice applies:
-+ *
-+ * Copyright 2006 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "main/context.h"
-+#include "main/framebuffer.h"
-+#include "main/api_arrayelt.h"
-+#include "swrast/swrast.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "tnl/tnl.h"
-+
-+#include "glamo_fbo.h"
-+#include "glamo_state.h"
-+#include "glamo_context.h"
-+#include "glamo_cmdq.h"
-+#include "glamo_regs.h"
-+
-+
-+static void glamoResizeBuffers(GLcontext *ctx, struct gl_framebuffer *fb,
-+                               GLuint width, GLuint height)
-+{
-+	struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb;
-+	int i;
-+
-+	_mesa_resize_framebuffer(ctx, fb, width, height);
-+
-+	fb->Initialized = GL_TRUE; /* XXX remove someday */
-+
-+	if (fb->Name != 0) {
-+		return;
-+	}
-+
-+	/* Make sure all window system renderbuffers are up to date */
-+	for (i = 0; i < 2; i++) {
-+		struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base;
-+
-+		/* only resize if size is changing */
-+		if (rb && (rb->Width != width || rb->Height != height)) {
-+			rb->AllocStorage(ctx, rb, rb->InternalFormat,
-+		                         width, height);
-+		}
-+	}
-+}
-+
-+
-+static void glamoClear(GLcontext *ctx, GLbitfield mask)
-+{
-+	glamoContext *gCtx;
-+	struct gl_framebuffer *fb;
-+	int i;
-+
-+	gCtx = GLAMO_CONTEXT(ctx);
-+	fb = ctx->DrawBuffer;
-+
-+	printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0],
-+	       ctx->Color.ClearColor[1], ctx->Color.ClearColor[2],
-+	       ctx->Color.ClearColor[3]); fflush(stdout);
-+
-+	for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
-+
-+		struct glamo_renderbuffer *grb;
-+
-+		grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]);
-+
-+		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_DST_X);
-+		glamoDRMAddData(gCtx, fb->_Xmin, 2);           /* dest X */
-+		glamoDRMAddData(gCtx, fb->_Ymin, 2);           /* dest Y */
-+		glamoDRMAddBO(gCtx, grb->bo);                  /* dest L/H */
-+		glamoDRMAddData(gCtx, grb->pitch & 0x7ff, 2);  /* dest pitch */
-+		glamoDRMAddData(gCtx, grb->height, 2);         /* dest height */
-+		glamoDRMAddData(gCtx, fb->_Xmax-fb->_Xmin, 2); /* width */
-+		glamoDRMAddData(gCtx, fb->_Ymax-fb->_Ymin, 2); /* height */
-+		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt L */
-+		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt H */
-+		glamoDRMAddData(gCtx, gCtx->col_clear, 2);     /* FG colour */
-+		glamoDRMDispatch(gCtx);
-+
-+		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_COMMAND1);
-+		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 1 */
-+		glamoDRMAddData(gCtx, 0xf0 << 8, 2); /* Cmd param 2 */
-+		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 3 */
-+		glamoDRMDispatch(gCtx);
-+
-+	}
-+}
-+
-+
-+static void glamoClearColor(GLcontext *ctx, const GLfloat color[4])
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	GLubyte col_byte[4];
-+
-+	printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2],
-+	       color[3]); fflush(stdout);
-+
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]);
-+
-+	gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1],
-+	                                     col_byte[2]);
-+}
-+
-+
-+static void glamoShadeModel(GLcontext *ctx, GLenum mode)
-+{
-+	printf("glamoShadeModel\n"); fflush(stdout);
-+}
-+
-+
-+static void glamoViewport(GLcontext *ctx, GLint x, GLint y,
-+                          GLsizei width, GLsizei height )
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	__DRIcontext *driContext = gCtx->driContext;
-+	void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
-+			 GLsizei w, GLsizei h);
-+
-+	if ( !driContext->driScreenPriv->dri2.enabled ) return;
-+
-+	/* TODO: Flush before fiddling with fake front buffer */
-+
-+	if ( ctx->DrawBuffer->Name == 0 ) {
-+
-+		glamo_update_renderbuffers(driContext,
-+		                           driContext->driDrawablePriv);
-+		if ( driContext->driDrawablePriv
-+		                              != driContext->driReadablePriv ) {
-+			glamo_update_renderbuffers(driContext,
-+				                   driContext->driReadablePriv);
-+		}
-+
-+	}
-+
-+	old_viewport = ctx->Driver.Viewport;
-+	ctx->Driver.Viewport = NULL;
-+	gCtx->driDrawable = driContext->driDrawablePriv;
-+	ctx->Driver.Viewport = old_viewport;
-+}
-+
-+
-+static void glamoUploadMatrix(struct glamo_context *gCtx, uint16_t mreg,
-+                              GLfloat *matrix)
-+{
-+	int i;
-+	char *type;
-+
-+	switch ( mreg ) {
-+	case G3D_MATRIX_MVP :
-+		type = "MVP"; break;
-+	case G3D_MATRIX_MV :
-+		type = "MV"; break;
-+	case G3D_MATRIX_IMVP :
-+		type = "inverse MVP"; break;
-+	default :
-+		type = "unknown"; break;
-+	}
-+	printf("Uploading %s matrix...\n", type);
-+
-+	glamoDRMStartBurst(gCtx, mreg);
-+	if ( mreg != G3D_MATRIX_IMVP ) {
-+		for ( i=0; i<16; i++ ) {
-+			glamoDRMAddData(gCtx, float7s16(matrix[i]), 4);
-+		}
-+	} else {
-+		/* Normal matrix needs special treatment */
-+		for ( i=0; i<3; i++ ) {
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i]), 4);
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i+1]), 4);
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i+2]), 4);
-+		}
-+	}
-+	glamoDRMDispatch(gCtx);
-+}
-+
-+
-+GLboolean glamoValidateState(GLcontext *ctx, GLuint new_state)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	if ( new_state & (_NEW_MODELVIEW|_NEW_PROJECTION) ) {
-+
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_MVP,
-+		                  ctx->_ModelProjectMatrix.m);
-+
-+		/* FIXME: The following two aren't needed unless lighting
-+		 * is in use... */
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_MV,
-+		                  ctx->ModelviewMatrixStack.Top->m);
-+		_math_matrix_alloc_inv(&(ctx->_ModelProjectMatrix));
-+		_math_matrix_analyse(&(ctx->_ModelProjectMatrix));
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_IMVP,
-+		                  ctx->_ModelProjectMatrix.inv);
-+	}
-+
-+	gCtx->new_state = 0;
-+	return GL_TRUE;
-+}
-+
-+
-+static void glamoUpdateState(GLcontext *ctx, GLbitfield new_state)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	printf("glamoUpdateState\n");
-+
-+	_swrast_InvalidateState(ctx, new_state);
-+	_swsetup_InvalidateState(ctx, new_state);
-+	_vbo_InvalidateState(ctx, new_state);
-+	_tnl_InvalidateState(ctx, new_state);
-+	_ae_invalidate_state(ctx, new_state);
-+
-+	/* Make a note that some state has changed,
-+	 * so that it can be sent to the GPU later. */
-+	gCtx->new_state |= new_state;
-+}
-+
-+
-+static void glamoFlush(GLcontext *ctx)
-+{
-+	printf("glamoFlush\n");
-+}
-+
-+
-+void glamoInitStateFuncs(GLcontext *ctx)
-+{
-+	ctx->Driver.UpdateState       = glamoUpdateState;
-+	ctx->Driver.Clear             = glamoClear;
-+	ctx->Driver.ClearColor        = glamoClearColor;
-+	ctx->Driver.ClearDepth        = NULL;
-+	ctx->Driver.ClearStencil      = NULL;
-+	ctx->Driver.AlphaFunc         = NULL;
-+	ctx->Driver.BlendFuncSeparate = NULL;
-+	ctx->Driver.ColorMask         = NULL;
-+	ctx->Driver.CullFace          = NULL;
-+	ctx->Driver.DepthMask         = NULL;
-+	ctx->Driver.DepthFunc         = NULL;
-+	ctx->Driver.DepthRange        = NULL;
-+	ctx->Driver.DrawBuffer        = NULL;
-+	ctx->Driver.Enable            = NULL;
-+	ctx->Driver.FrontFace         = NULL;
-+	ctx->Driver.Fogfv             = NULL;
-+	ctx->Driver.Hint              = NULL;
-+	ctx->Driver.Lightfv           = NULL;
-+	ctx->Driver.LogicOpcode       = NULL;
-+	ctx->Driver.PolygonMode       = NULL;
-+	ctx->Driver.PolygonStipple    = NULL;
-+	ctx->Driver.ReadBuffer        = NULL;
-+	ctx->Driver.RenderMode        = NULL;
-+	ctx->Driver.Scissor           = NULL;
-+	ctx->Driver.ShadeModel        = glamoShadeModel;
-+	ctx->Driver.LightModelfv      = NULL;
-+	ctx->Driver.Viewport          = glamoViewport;
-+	ctx->Driver.ResizeBuffers     = glamoResizeBuffers;
-+	ctx->Driver.Flush             = glamoFlush;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_state.h b/src/mesa/drivers/dri/glamo/glamo_state.h
-new file mode 100644
-index 0000000..98f0b97
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_state.h
-@@ -0,0 +1,34 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_state.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_STATE_H
-+#define __GLAMO_STATE_H
-+
-+#include "main/context.h"
-+
-+extern void glamoInitStateFuncs(GLcontext *ctx);
-+
-+#endif   /* __GLAMO_STATE_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.c b/src/mesa/drivers/dri/glamo/glamo_tris.c
-new file mode 100644
-index 0000000..6c6b5a6
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_tris.c
-@@ -0,0 +1,310 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Based on intel_tris.c, to which the following notice applies:
-+ *
-+ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ *
-+ */
-+
-+
-+#include <glamo_bo.h>
-+#include <glamo_bo_gem.h>
-+#include <glamo_drm.h>
-+
-+#include "main/mtypes.h"
-+#include "swrast/swrast.h"
-+#include "tnl/t_context.h"
-+#include "tnl/t_vertex.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "glamo_tris.h"
-+#include "glamo_context.h"
-+
-+
-+static void glamoRunPipeline(GLcontext *ctx)
-+{
-+	printf("glamoRunPipeline\n");
-+
-+	/* TODO: Emit state */
-+
-+	_tnl_run_pipeline(ctx);
-+}
-+
-+
-+static void glamoRenderStart(GLcontext *ctx)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	/* Decide which attributes will be used */
-+	gCtx->vertex_attrs[0].attrib = _TNL_ATTRIB_POS;
-+	gCtx->vertex_attrs[0].format = EMIT_4F;
-+
-+	gCtx->vertex_size = _tnl_install_attrs(ctx, gCtx->vertex_attrs, 1,
-+	                                       NULL, 0);
-+}
-+
-+
-+static void glamoRenderFinish(GLcontext *ctx)
-+{
-+	printf("glamoRenderFinish\n");
-+}
-+
-+
-+static void glamoPrimitiveNotify(GLcontext *ctx, GLenum prim)
-+{
-+	printf("glamoPrimitiveNotify\n");
-+}
-+
-+
-+uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, unsigned int count)
-+{
-+	uint32_t *addr;
-+
-+	printf("glamoGetPrimSpace\n");
-+
-+	/* Check for space in the existing VB */
-+	if (gCtx->prim.vb_bo == NULL || (gCtx->prim.current_offset +
-+	                           count * gCtx->vertex_size) > GLAMO_VB_SIZE) {
-+
-+		/* Not enough space, or no VB existing. Start a new one... */
-+		if (gCtx->prim.vb == NULL) {
-+			printf("Allocated %i bytes\n", GLAMO_VB_SIZE);
-+			gCtx->prim.vb = malloc(GLAMO_VB_SIZE);
-+		}
-+		gCtx->prim.vb_bo = glamo_bo_open(gCtx->glamoScreen->bom, 0,
-+		                                 GLAMO_VB_SIZE, 4,
-+		                                 GLAMO_GEM_DOMAIN_VRAM, 0);
-+		gCtx->prim.start_offset = 0;
-+		gCtx->prim.current_offset = 0;
-+	}
-+
-+	addr = (uint32_t *)(gCtx->prim.vb + gCtx->prim.current_offset);
-+	gCtx->prim.current_offset += gCtx->vertex_size * count;
-+	gCtx->prim.count += count;
-+
-+	return addr;
-+}
-+
-+
-+#define COPY_DWORDS( j, vb, vertsize, v )	\
-+do {						\
-+   for ( j = 0 ; j < vertsize ; j++ ) {		\
-+      vb[j] = ((GLuint *)v)[j];			\
-+   }						\
-+   vb += vertsize;				\
-+} while (0)
-+
-+
-+static void glamo_draw_triangle(struct glamo_context *gCtx,
-+                                glamoVertexPtr v0, glamoVertexPtr v1,
-+                                glamoVertexPtr v2)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 3);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v2);
-+}
-+
-+
-+static void glamo_draw_line(struct glamo_context *gCtx,
-+                            glamoVertexPtr v0, glamoVertexPtr v1)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
-+}
-+
-+
-+static void glamo_draw_point(struct glamo_context *gCtx, glamoVertexPtr v0)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+}
-+
-+
-+#define TRI( a, b, c )                          \
-+do {                                            \
-+        glamo_draw_triangle(gCtx, a, b, c  );   \
-+} while (0)
-+
-+
-+#define QUAD( a, b, c, d )                      \
-+printf("Drawing a quad\n");                     \
-+do {                                            \
-+        glamo_draw_triangle(gCtx, a, b, d);     \
-+        glamo_draw_triangle(gCtx, b, c, d);     \
-+} while (0)
-+
-+
-+#define LINE(v0, v1)                            \
-+do {                                            \
-+        glamo_draw_line(gCtx, v0, v1);          \
-+} while (0)
-+
-+
-+#define POINT(v0)                               \
-+do {                                            \
-+        glamo_draw_point(gCtx, v0);             \
-+} while (0)
-+
-+
-+#define IND (0)
-+#define TAG(x) x
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+
-+static void init_rast_tab()
-+{
-+	init();
-+	init_offset();
-+	init_twoside();
-+	init_twoside_offset();
-+	init_unfilled();
-+	init_offset_unfilled();
-+	init_twoside_unfilled();
-+	init_twoside_offset_unfilled();
-+	init_fallback();
-+	init_offset_fallback();
-+	init_twoside_fallback();
-+	init_twoside_offset_fallback();
-+	init_unfilled_fallback();
-+	init_offset_unfilled_fallback();
-+	init_twoside_unfilled_fallback();
-+	init_twoside_offset_unfilled_fallback();
-+}
-+
-+
-+void glamoInitTriFuncs(GLcontext *ctx)
-+{
-+	TNLcontext *tnl = TNL_CONTEXT(ctx);
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	static int firsttime = 1;
-+
-+	if (firsttime) {
-+		init_rast_tab();
-+		firsttime = 0;
-+	}
-+
-+	gCtx->prim.start_offset = 0;
-+	gCtx->prim.current_offset = 0;
-+	gCtx->prim.vb_bo = NULL;
-+	gCtx->prim.vb = NULL;
-+	gCtx->prim.count = 0;
-+
-+	tnl->Driver.RunPipeline = glamoRunPipeline;
-+	tnl->Driver.Render.Start = glamoRenderStart;
-+	tnl->Driver.Render.Finish = glamoRenderFinish;
-+	tnl->Driver.Render.PrimitiveNotify = glamoPrimitiveNotify;
-+	tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
-+	tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
-+	tnl->Driver.Render.CopyPV = _tnl_copy_pv;
-+	tnl->Driver.Render.Interp = _tnl_interp;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.h b/src/mesa/drivers/dri/glamo/glamo_tris.h
-new file mode 100644
-index 0000000..ba8f997
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_tris.h
-@@ -0,0 +1,38 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_TRIS_H
-+#define __GLAMO_TRIS_H
-+
-+#include "main/mtypes.h"
-+
-+#include "glamo_context.h"
-+
-+/* Amount of space reserved for vertex submission */
-+#define GLAMO_VB_SIZE (32*1024)
-+
-+extern void glamoInitTriFuncs(GLcontext *ctx);
-+extern uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx,
-+                                   unsigned int count);
-+
-+#endif   /* __GLAMO_TRIS_H */
diff --git a/recipes/mesa/mesa-dri-glsl-native_7.8.2.bb b/recipes/mesa/mesa-dri-glsl-native_7.8.2.bb
new file mode 100644
index 0000000..dd24f16
--- /dev/null
+++ b/recipes/mesa/mesa-dri-glsl-native_7.8.2.bb
@@ -0,0 +1,19 @@
+inherit native
+
+DEPENDS = "makedepend-native"
+
+SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive"
+SRC_URI[archive.md5sum] = "6be2d343a0089bfd395ce02aaf8adb57"
+SRC_URI[archive.sha256sum] = "505bf418dceba05837f4ea1b1972b9620c35f8cb94bc4d1e6d573c15f562576d"
+
+S = "${WORKDIR}/Mesa-7.8.2/src/glsl/"
+
+do_configure_prepend() {
+  ln -s ${S}/../../configs/default ${S}/../../configs/current
+}
+
+NATIVE_INSTALL_WORKS = "1"
+do_install() {
+  install -d ${bindir}
+  install -m 755 ${S}/apps/compile ${bindir}/glsl-compile
+}
diff --git a/recipes/mesa/mesa-dri-glsl-native_7.8.bb b/recipes/mesa/mesa-dri-glsl-native_7.8.bb
deleted file mode 100644
index eef5733..0000000
--- a/recipes/mesa/mesa-dri-glsl-native_7.8.bb
+++ /dev/null
@@ -1,20 +0,0 @@
-inherit native
-
-PR = "0"
-
-DEPENDS = "makedepend-native"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive"
-SRC_URI[archive.md5sum] = "85cb891eecb89aae4fdd3499cccd934b"
-SRC_URI[archive.sha256sum] = "8c85db5844303b806b18fc6bd40a9dccb02d90b54878a94f910674673ba0aa35"
-
-S = "${WORKDIR}/Mesa-7.8/src/glsl/"
-
-do_configure_prepend() {
-  ln -s ${S}/../../configs/default ${S}/../../configs/current
-}
-
-do_stage() {
-  install -d ${bindir}
-  install -m 755 ${S}/apps/compile ${bindir}/glsl-compile
-}
diff --git a/recipes/mesa/mesa-dri_7.8.1.bb b/recipes/mesa/mesa-dri_7.8.1.bb
deleted file mode 100644
index 5609cb4..0000000
--- a/recipes/mesa/mesa-dri_7.8.1.bb
+++ /dev/null
@@ -1,43 +0,0 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto expat"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS} makedepend-native mesa-dri-glsl-native"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-	   file://fix-progs-makefile.patch \
-	   file://glamo.patch \
-          "
-SRC_URI[archive.md5sum] = "25ec15f8e41fde6d206118cc786dbac4"
-SRC_URI[archive.sha256sum] = "b0b46e5abfd75db44501e308125fa92bcf1c91d91e97a043a3b1764cfa0907fa"
-SRC_URI[demos.md5sum] = "9ef47f911869657c6bf2f43ebce86b61"
-SRC_URI[demos.sha256sum] = "e9f20b9345240064ac35ec914ebce63322a96d3f7c566963791d0daf7e7a93e5"
-
-PR = "${INC_PR}.2"
-
-# most of our targets do not have DRI so will use mesa-xlib
-DEFAULT_PREFERENCE = "-1"
-DEFAULT_PREFERENCE_shr = "2"
-
-# ASUS EeePC 901 has DRI support so use mesa-dri by default
-DEFAULT_PREFERENCE_eee901 = "1"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN} += "${libdir}/dri/*.so \
-                ${libdir}/egl/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/* \
-                    ${libdir}/egl/.debug/*"
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-EXTRA_OECONF += "--with-driver=dri --disable-glx-tls --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-EXTRA_OECONF_shr += "--with-driver=dri --disable-glx-tls --disable-gallium \
- --disable-gallium-intel --with-dri-drivers=swrast,${MACHINE_DRI_MODULES} \
- ${@base_conditional( 'MACHINE',"htcdream", "--disable-egl", "",d)} "
-
-# We need glsl-compile built for buildhost arch instead of target (is provided by mesa-dri-glsl-native)"
-do_configure_prepend() {
-  sed -i "s#^GLSL_CL = .*\$#GLSL_CL = ${STAGING_BINDIR_NATIVE}/glsl-compile#g" ${S}/src/mesa/shader/slang/library/Makefile
-}
diff --git a/recipes/mesa/mesa-dri_7.8.2.bb b/recipes/mesa/mesa-dri_7.8.2.bb
new file mode 100644
index 0000000..356c284
--- /dev/null
+++ b/recipes/mesa/mesa-dri_7.8.2.bb
@@ -0,0 +1,43 @@
+include mesa-common.inc
+
+PROTO_DEPS = "xf86driproto glproto dri2proto expat"
+LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
+
+DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS} makedepend-native mesa-dri-glsl-native"
+
+SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
+           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
+	   file://fix-progs-makefile.patch \
+	   file://glamo.patch \
+          "
+SRC_URI[archive.md5sum] = "6be2d343a0089bfd395ce02aaf8adb57"
+SRC_URI[archive.sha256sum] = "505bf418dceba05837f4ea1b1972b9620c35f8cb94bc4d1e6d573c15f562576d"
+SRC_URI[demos.md5sum] = "757d9e2e06f48b1a52848be9b0307ced"
+SRC_URI[demos.sha256sum] = "ea7b9ebfb7a80de2b275c0c9124c8a505382ec48411a2794ab82542f9885ac3c"
+
+PR = "${INC_PR}.0"
+
+# most of our targets do not have DRI so will use mesa-xlib
+DEFAULT_PREFERENCE = "-1"
+DEFAULT_PREFERENCE_shr = "2"
+
+# ASUS EeePC 901 has DRI support so use mesa-dri by default
+DEFAULT_PREFERENCE_eee901 = "1"
+
+PACKAGES =+ "${PN}-xprogs"
+
+FILES_${PN} += "${libdir}/dri/*.so \
+                ${libdir}/egl/*.so"
+FILES_${PN}-dbg += "${libdir}/dri/.debug/* \
+                    ${libdir}/egl/.debug/*"
+FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
+
+EXTRA_OECONF += "--with-driver=dri --disable-glx-tls --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
+EXTRA_OECONF_shr += "--with-driver=dri --disable-glx-tls --disable-gallium \
+ --disable-gallium-intel --with-dri-drivers=swrast,${MACHINE_DRI_MODULES} \
+ ${@base_conditional( 'MACHINE',"htcdream", "--disable-egl", "",d)} "
+
+# We need glsl-compile built for buildhost arch instead of target (is provided by mesa-dri-glsl-native)"
+do_configure_prepend() {
+  sed -i "s#^GLSL_CL = .*\$#GLSL_CL = ${STAGING_BINDIR_NATIVE}/glsl-compile#g" ${S}/src/mesa/shader/slang/library/Makefile
+}
diff --git a/recipes/mesa/mesa-dri_7.8.bb b/recipes/mesa/mesa-dri_7.8.bb
deleted file mode 100644
index c5f95ff..0000000
--- a/recipes/mesa/mesa-dri_7.8.bb
+++ /dev/null
@@ -1,41 +0,0 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto expat"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS} makedepend-native mesa-dri-glsl-native"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-	   file://fix-progs-makefile.patch \
-	   file://glamo.patch \
-          "
-SRC_URI[archive.md5sum] = "85cb891eecb89aae4fdd3499cccd934b"
-SRC_URI[archive.sha256sum] = "8c85db5844303b806b18fc6bd40a9dccb02d90b54878a94f910674673ba0aa35"
-SRC_URI[demos.md5sum] = "9fe8ec184c7f78691e43c4c0a7f97d56"
-SRC_URI[demos.sha256sum] = "5bf65f03ddcd04b02e9ca044285f8754decee67eb274191da1f31627f1d84b0e"
-
-PR = "${INC_PR}.1"
-
-# most of our targets do not have DRI so will use mesa-xlib
-DEFAULT_PREFERENCE = "-1"
-DEFAULT_PREFERENCE_shr = "2"
-
-# ASUS EeePC 901 has DRI support so use mesa-dri by default
-DEFAULT_PREFERENCE_eee901 = "1"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN} += "${libdir}/dri/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-EXTRA_OECONF += "--with-driver=dri --disable-glx-tls --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-EXTRA_OECONF_shr += "--with-driver=dri --disable-glx-tls --disable-gallium \
- --disable-gallium-intel --with-dri-drivers=swrast,${MACHINE_DRI_MODULES} \
- ${@base_conditional( 'MACHINE',"htcdream", "--disable-egl", "",d)} "
-
-# We need glsl-compile built for buildhost arch instead of target (is provided by mesa-dri-glsl-native)"
-do_configure_prepend() {
-  sed -i "s#^GLSL_CL = .*\$#GLSL_CL = ${STAGING_BINDIR_NATIVE}/glsl-compile#g" ${S}/src/mesa/shader/slang/library/Makefile
-}
diff --git a/recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch b/recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch
new file mode 100644
index 0000000..40e6a1b
--- /dev/null
+++ b/recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch
@@ -0,0 +1,81 @@
+From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
+From: Martin Jansa <Martin.Jansa@gmail.com>
+Date: Thu, 4 Mar 2010 14:16:27 +0100
+Subject: [PATCH] fix libs
+
+---
+ progs/demos/Makefile   |    2 +-
+ progs/glsl/Makefile    |    2 +-
+ progs/redbook/Makefile |    2 +-
+ progs/samples/Makefile |    2 +-
+ progs/xdemos/Makefile  |    2 +-
+ 5 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/progs/demos/Makefile b/progs/demos/Makefile
+index 5b1d2a0..121b862 100644
+--- a/progs/demos/Makefile
++++ b/progs/demos/Makefile
+@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
+ 	$(APP_LIB_DEPS)
+ 
+ PROGS = \
+diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
+index 3b5a595..836c4ac 100644
+--- a/progs/glsl/Makefile
++++ b/progs/glsl/Makefile
+@@ -10,7 +10,7 @@ LIB_DEP = \
+ 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
+ 	-l$(GL_LIB) $(APP_LIB_DEPS)
+ 
+ # using : to avoid APP_CC pointing to CC loop
+diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
+index b41e488..95ed746 100644
+--- a/progs/redbook/Makefile
++++ b/progs/redbook/Makefile
+@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
+ 
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = aaindex \
+ 	aapoly \
+diff --git a/progs/samples/Makefile b/progs/samples/Makefile
+index 64fa47a..9f72c8b 100644
+--- a/progs/samples/Makefile
++++ b/progs/samples/Makefile
+@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
+ 
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
+ 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
+diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
+index f866a32..c0f4e06 100644
+--- a/progs/xdemos/Makefile
++++ b/progs/xdemos/Makefile
+@@ -11,7 +11,7 @@
+ # Add X11 and pthread libs to satisfy GNU gold.
+ APP_LIB_DEPS += -lX11 -lpthread
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = \
+ 	corender \
+-- 
+1.7.0
+
diff --git a/recipes/mesa/mesa-xlib-7.8/fix-progs-makefile.patch b/recipes/mesa/mesa-xlib-7.8/fix-progs-makefile.patch
deleted file mode 100644
index 40e6a1b..0000000
--- a/recipes/mesa/mesa-xlib-7.8/fix-progs-makefile.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
-From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Thu, 4 Mar 2010 14:16:27 +0100
-Subject: [PATCH] fix libs
-
----
- progs/demos/Makefile   |    2 +-
- progs/glsl/Makefile    |    2 +-
- progs/redbook/Makefile |    2 +-
- progs/samples/Makefile |    2 +-
- progs/xdemos/Makefile  |    2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index 5b1d2a0..121b862 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
- 	$(APP_LIB_DEPS)
- 
- PROGS = \
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 3b5a595..836c4ac 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -10,7 +10,7 @@ LIB_DEP = \
- 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
- 	-l$(GL_LIB) $(APP_LIB_DEPS)
- 
- # using : to avoid APP_CC pointing to CC loop
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index b41e488..95ed746 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = aaindex \
- 	aapoly \
-diff --git a/progs/samples/Makefile b/progs/samples/Makefile
-index 64fa47a..9f72c8b 100644
---- a/progs/samples/Makefile
-+++ b/progs/samples/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
-diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
-index f866a32..c0f4e06 100644
---- a/progs/xdemos/Makefile
-+++ b/progs/xdemos/Makefile
-@@ -11,7 +11,7 @@
- # Add X11 and pthread libs to satisfy GNU gold.
- APP_LIB_DEPS += -lX11 -lpthread
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = \
- 	corender \
--- 
-1.7.0
-
diff --git a/recipes/mesa/mesa-xlib_7.8.2.bb b/recipes/mesa/mesa-xlib_7.8.2.bb
new file mode 100644
index 0000000..6c0e7ea
--- /dev/null
+++ b/recipes/mesa/mesa-xlib_7.8.2.bb
@@ -0,0 +1,20 @@
+include mesa-common.inc
+
+PROTO_DEPS = "xf86driproto glproto"
+LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
+
+DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
+
+SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
+           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
+           file://fix-progs-makefile.patch \
+          "
+
+SRC_URI[archive.md5sum] = "85cb891eecb89aae4fdd3499cccd934b"
+SRC_URI[archive.sha256sum] = "8c85db5844303b806b18fc6bd40a9dccb02d90b54878a94f910674673ba0aa35"
+SRC_URI[demos.md5sum] = "9fe8ec184c7f78691e43c4c0a7f97d56"
+SRC_URI[demos.sha256sum] = "5bf65f03ddcd04b02e9ca044285f8754decee67eb274191da1f31627f1d84b0e"
+
+PR = "${INC_PR}.0"
+
+EXTRA_OECONF += "--disable-gallium --with-driver=xlib"
diff --git a/recipes/mesa/mesa-xlib_7.8.bb b/recipes/mesa/mesa-xlib_7.8.bb
deleted file mode 100644
index 6c0e7ea..0000000
--- a/recipes/mesa/mesa-xlib_7.8.bb
+++ /dev/null
@@ -1,20 +0,0 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto"
-LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-           file://fix-progs-makefile.patch \
-          "
-
-SRC_URI[archive.md5sum] = "85cb891eecb89aae4fdd3499cccd934b"
-SRC_URI[archive.sha256sum] = "8c85db5844303b806b18fc6bd40a9dccb02d90b54878a94f910674673ba0aa35"
-SRC_URI[demos.md5sum] = "9fe8ec184c7f78691e43c4c0a7f97d56"
-SRC_URI[demos.sha256sum] = "5bf65f03ddcd04b02e9ca044285f8754decee67eb274191da1f31627f1d84b0e"
-
-PR = "${INC_PR}.0"
-
-EXTRA_OECONF += "--disable-gallium --with-driver=xlib"
diff --git a/recipes/mesa/mesa_7.8.2.bb b/recipes/mesa/mesa_7.8.2.bb
new file mode 100644
index 0000000..bbd0c41
--- /dev/null
+++ b/recipes/mesa/mesa_7.8.2.bb
@@ -0,0 +1,8 @@
+# This is a dummy package so OE can use the poky mesa files
+require mesa-dri_${PV}.bb
+
+FILESPATHPKG =. "mesa-dri-${PV}:"
+
+PR = "${INC_PR}.1"
+
+EXTRA_OECONF += "--disable-egl"
diff --git a/recipes/mesa/mesa_7.8.bb b/recipes/mesa/mesa_7.8.bb
deleted file mode 100644
index bbd0c41..0000000
--- a/recipes/mesa/mesa_7.8.bb
+++ /dev/null
@@ -1,8 +0,0 @@
-# This is a dummy package so OE can use the poky mesa files
-require mesa-dri_${PV}.bb
-
-FILESPATHPKG =. "mesa-dri-${PV}:"
-
-PR = "${INC_PR}.1"
-
-EXTRA_OECONF += "--disable-egl"
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 7/9] mesa: move common definitions to include file, change SRC_URI to freedesktop for releases newer than 7.5
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (5 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 6/9] mesa: move 7.8 release to latest minor 7.8.2 Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-25 12:19 ` [PATCH 8/9] htcdream: don't set PREFERRED_PROVIDER_virtual/libgl to mesa-dri Martin Jansa
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

* drop eee901 override (no such machine in OE, dropped from poky
  http://git.pokylinux.org/cgit.cgi/poky/commit/?id=542eb3b16dc1c6fa7920257219ed5dac0b95c257)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 recipes/mesa/README                                |   12 +
 recipes/mesa/mesa-7.2.inc                          |    7 +
 recipes/mesa/mesa-7.6.inc                          |    6 +
 recipes/mesa/mesa-7.8.2.inc                        |   13 +
 recipes/mesa/mesa-7.8.2/glamo.patch                | 2386 ++++++++++++++++++++
 recipes/mesa/mesa-common.inc                       |   20 +-
 .../mesa/mesa-dri-7.8.2/fix-progs-makefile.patch   |   82 -
 recipes/mesa/mesa-dri-7.8.2/glamo.patch            | 2386 --------------------
 recipes/mesa/mesa-dri.inc                          |    8 +
 recipes/mesa/mesa-dri_7.2.bb                       |   29 +-
 recipes/mesa/mesa-dri_7.6.bb                       |   34 +-
 recipes/mesa/mesa-dri_7.8.2.bb                     |   40 +-
 recipes/mesa/mesa-dri_git.bb                       |   19 +-
 .../mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch  |   81 -
 recipes/mesa/mesa-xlib.inc                         |    2 +
 recipes/mesa/mesa-xlib_7.2.bb                      |   26 +-
 recipes/mesa/mesa-xlib_7.6.bb                      |   21 +-
 recipes/mesa/mesa-xlib_7.8.2.bb                    |   22 +-
 recipes/mesa/mesa/fix-progs-makefile.patch         |   82 +
 19 files changed, 2553 insertions(+), 2723 deletions(-)
 create mode 100644 recipes/mesa/README
 create mode 100644 recipes/mesa/mesa-7.2.inc
 create mode 100644 recipes/mesa/mesa-7.6.inc
 create mode 100644 recipes/mesa/mesa-7.8.2.inc
 create mode 100644 recipes/mesa/mesa-7.8.2/glamo.patch
 delete mode 100644 recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch
 delete mode 100644 recipes/mesa/mesa-dri-7.8.2/glamo.patch
 create mode 100644 recipes/mesa/mesa-dri.inc
 delete mode 100644 recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch
 create mode 100644 recipes/mesa/mesa-xlib.inc
 create mode 100644 recipes/mesa/mesa/fix-progs-makefile.patch

diff --git a/recipes/mesa/README b/recipes/mesa/README
new file mode 100644
index 0000000..3c6de3e
--- /dev/null
+++ b/recipes/mesa/README
@@ -0,0 +1,12 @@
+mesa-common.inc
+* Settings shared by ALL recipes
+
+mesa-${PV}.inc
+* Settings for particular version, mostly checksums and additional patches
+* Patches are stored mesa-${PV} dir and -dri and xlib has adjusted FILESPATHPKG
+
+mesa-dri.inc
+* Setting shared by ALL dri recipes - defines what is mesa-dri
+
+mesa-xlib.inc
+* Setting shared by ALL xlib recipes - defines what is mesa-xlib
diff --git a/recipes/mesa/mesa-7.2.inc b/recipes/mesa/mesa-7.2.inc
new file mode 100644
index 0000000..88513ab
--- /dev/null
+++ b/recipes/mesa/mesa-7.2.inc
@@ -0,0 +1,7 @@
+SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2;name=archive \
+           ${SOURCEFORGE_MIRROR}/mesa3d/MesaDemos-${PV}.tar.bz2;name=demos "
+
+SRC_URI[archive.md5sum] = "04d379292e023df0b0266825cb0dbde5"
+SRC_URI[archive.sha256sum] = "a9cc62ab760afeebcb1319a193508734a2d470cab8effab2776a2d3c65bd9cd2"
+SRC_URI[demos.md5sum] = "22e03dc4038cd63f32c21eb60994892b"
+SRC_URI[demos.sha256sum] = "3d73988ad3e87f6084a4593cc6b3aac63aca3e893d3e9409d892a6f51558e4c4"
diff --git a/recipes/mesa/mesa-7.6.inc b/recipes/mesa/mesa-7.6.inc
new file mode 100644
index 0000000..76b41c6
--- /dev/null
+++ b/recipes/mesa/mesa-7.6.inc
@@ -0,0 +1,6 @@
+SRC_URI[archive.md5sum] = "8c75f90cd0303cfac9e4b6d54f6759ca"
+SRC_URI[archive.sha256sum] = "782a7b2810b1c466b3a994eba96485b59b47cc1120c0caa24de1aecf1e013830"
+SRC_URI[demos.md5sum] = "0ede7adf217951acd90dbe4551210c07"
+SRC_URI[demos.sha256sum] = "2fdf09fd7967fb1946e7f6af07d39c9fb695c373e1bad3855d3c3fbece5badd0"
+
+EXTRA_OECONF += " --disable-gallium"
diff --git a/recipes/mesa/mesa-7.8.2.inc b/recipes/mesa/mesa-7.8.2.inc
new file mode 100644
index 0000000..a20e290
--- /dev/null
+++ b/recipes/mesa/mesa-7.8.2.inc
@@ -0,0 +1,13 @@
+SRC_URI += " \ 
+            file://fix-progs-makefile.patch \
+            file://glamo.patch \
+           "
+
+SRC_URI[archive.md5sum] = "6be2d343a0089bfd395ce02aaf8adb57"
+SRC_URI[archive.sha256sum] = "505bf418dceba05837f4ea1b1972b9620c35f8cb94bc4d1e6d573c15f562576d"
+SRC_URI[demos.md5sum] = "757d9e2e06f48b1a52848be9b0307ced"
+SRC_URI[demos.sha256sum] = "ea7b9ebfb7a80de2b275c0c9124c8a505382ec48411a2794ab82542f9885ac3c"
+
+DEFAULT_PREFERENCE_shr = "2"
+
+EXTRA_OECONF += " --disable-gallium"
diff --git a/recipes/mesa/mesa-7.8.2/glamo.patch b/recipes/mesa/mesa-7.8.2/glamo.patch
new file mode 100644
index 0000000..52b4f3f
--- /dev/null
+++ b/recipes/mesa/mesa-7.8.2/glamo.patch
@@ -0,0 +1,2386 @@
+diff --git a/configure.ac b/configure.ac
+index 61487c3..c4952bf 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -125,6 +125,9 @@ dnl Add flags for gcc and g++
+ if test "x$GCC" = xyes; then
+     CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
+ 
++    # Work around GCC bug #39501
++    CFLAGS="$CFLAGS -fno-finite-math-only"
++
+     # Enable -fvisibility=hidden if using a gcc that supports it
+     save_CFLAGS="$CFLAGS"
+     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
+@@ -138,6 +141,9 @@ fi
+ if test "x$GXX" = xyes; then
+     CXXFLAGS="$CXXFLAGS -Wall"
+ 
++    # Work around GCC bug #39501
++    CXXFLAGS="$CXXFLAGS -fno-finite-math-only"
++
+     # Work around aliasing bugs - developers should comment this out
+     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+ fi
+diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile
+new file mode 100644
+index 0000000..e77193d
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/Makefile
+@@ -0,0 +1,22 @@
++# src/mesa/drivers/dri/glamo/Makefile
++
++TOP = ../../../../..
++include $(TOP)/configs/current
++
++LIBNAME = glamo_dri.so
++
++DRIVER_SOURCES = \
++	glamo_screen.c glamo_context.c glamo_state.c glamo_fbo.c glamo_tris.c \
++	glamo_cmdq.c glamo_render.c
++
++C_SOURCES = \
++	$(COMMON_SOURCES) \
++	$(DRIVER_SOURCES)
++
++ASM_SOURCES =
++
++DRI_LIB_DEPS += -ldrm_glamo
++
++include ../Makefile.template
++
++symlinks:
+diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.c b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
+new file mode 100644
+index 0000000..1334f8e
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
+@@ -0,0 +1,110 @@
++/*
++ * Command queue submission via DRM
++ *
++ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++
++#include <stdint.h>
++#include <stdlib.h>
++#include <drm.h>
++#include <glamo_drm.h>
++#include <glamo_bo.h>
++
++#include "glamo_context.h"
++#include "glamo_cmdq.h"
++
++
++/* Submit the prepared command sequence to the kernel */
++void glamoDRMDispatch(glamoContext *gCtx)
++{
++	drm_glamo_cmd_burst_t burst;
++	int r;
++
++	burst.base = gCtx->cmd_burst_base;
++	burst.data = gCtx->cmdq_drm;
++	burst.bufsz = gCtx->cmdq_drm_used * 2;	/* -> bytes */
++	burst.nobjs = gCtx->cmdq_obj_used;
++	burst.objs = gCtx->cmdq_objs;
++	burst.obj_pos = gCtx->cmdq_obj_pos;
++
++	r = drmCommandWrite(gCtx->drm_fd, DRM_GLAMO_CMDBURST,
++	                    &burst, sizeof(burst));
++	if ( r != 0 ) {
++		fprintf(stderr, "DRM_GLAMO_CMDBURST failed\n");
++	}
++
++	/* Reset counts to zero for the next sequence */
++	gCtx->cmdq_obj_used = 0;
++	gCtx->cmdq_drm_used = 0;
++}
++
++
++void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len)
++{
++	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
++		fprintf(stderr, "Burst command too large\n");
++		return;
++	}
++
++	/* Record command */
++	if ( len == 2 ) {
++		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff;
++	} else if ( len == 4 ) {
++		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0x0000ffff;
++		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff0000;
++	} else {
++		fprintf(stderr, "Wrong command length!\n");
++	}
++}
++
++
++void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo)
++{
++	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
++		fprintf(stderr, "Burst command too large\n");
++		return;
++	}
++
++	/* Record object position */
++	gCtx->cmdq_objs[gCtx->cmdq_obj_used] = bo->handle;
++	/* -> bytes */
++	gCtx->cmdq_obj_pos[gCtx->cmdq_obj_used] = gCtx->cmdq_drm_used * 2;
++	gCtx->cmdq_obj_used++;
++
++	/* Record command */
++	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
++	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
++}
++
++
++void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base)
++{
++	gCtx->cmd_burst_base = base;
++}
++
++
++void glamoInitCmdqCache(glamoContext *gCtx)
++{
++	gCtx->cmdq_objs = malloc(1024);
++	gCtx->cmdq_obj_pos = malloc(1024);
++	gCtx->cmdq_obj_used = 0;
++	gCtx->cmdq_drm_used = 0;
++	gCtx->cmdq_drm_size = 4 * 1024;
++	gCtx->cmdq_drm = malloc(gCtx->cmdq_drm_size);
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.h b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
+new file mode 100644
+index 0000000..7420d7b
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
+@@ -0,0 +1,33 @@
++/*
++ * Command queue submission via DRM
++ *
++ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++
++#include <stdint.h>
++#include <glamo_bo.h>
++
++#include "glamo_context.h"
++
++
++extern void glamoDRMDispatch(glamoContext *gCtx);
++extern void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo);
++extern void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len);
++extern void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base);
++extern void glamoInitCmdqCache(glamoContext *gCtx);
+diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
+new file mode 100644
+index 0000000..527654f
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_context.c
+@@ -0,0 +1,360 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_context.c (c) 2003 Eric Anholt
++ *              and radeon_common_context.c
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "dri_util.h"
++#include "drirenderbuffer.h"
++#include "utils.h"
++
++#include "swrast/swrast.h"
++#include "swrast_setup/swrast_setup.h"
++#include "drivers/common/driverfuncs.h"
++#include "vbo/vbo.h"
++#include "tnl/tnl.h"
++#include "tnl/t_pipeline.h"
++#include "main/state.h"
++
++#include "glamo_context.h"
++#include "glamo_screen.h"
++#include "glamo_state.h"
++#include "glamo_fbo.h"
++#include "glamo_tris.h"
++#include "glamo_render.h"
++#include "glamo_cmdq.h"
++
++#include <glamo_bo.h>
++#include <glamo_bo_gem.h>
++#include <glamo_drm.h>
++
++
++#define DRIVER_DATE  "20090913"
++
++
++static inline struct glamo_renderbuffer *glamo_get_renderbuffer(
++                                                      struct gl_framebuffer *fb,
++                                                      int att_index)
++{
++	if ( att_index >= 0 ) {
++		struct glamo_renderbuffer *gr;
++		gr = glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer);
++		return gr;
++	} else {
++		return NULL;
++	}
++}
++
++
++static const GLubyte *glamoGetString(GLcontext *ctx, GLenum name)
++{
++	static char buffer[128];
++
++	switch (name) {
++	case GL_VENDOR:
++		return (GLubyte *)"Thomas White";
++	case GL_RENDERER: {
++		driGetRendererString(buffer, "Glamo", DRIVER_DATE, 0);
++		return (GLubyte *) buffer;
++	}
++	default:
++		return 0;
++	}
++}
++
++
++/* Called when Mesa needs to know the size of the framebuffer */
++static void glamoBufferSize(GLframebuffer *buffer,
++                            GLuint *width, GLuint *height)
++{
++	GET_CURRENT_CONTEXT(ctx);
++	glamoContextPtr glamo = GLAMO_CONTEXT(ctx);
++
++	*width = glamo->driDrawable->w;
++	*height = glamo->driDrawable->h;
++}
++
++
++GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
++                             __DRIcontext *driContextPriv,
++                             void *sharedContextPrivate)
++{
++	GLcontext *ctx, *shareCtx;
++	__DRIscreen *sPriv = driContextPriv->driScreenPriv;
++	glamoContextPtr context;
++	glamoScreenPtr glamoScreen;
++	struct dd_function_table functions;
++
++	context = (glamoContextPtr)CALLOC(sizeof(*context));
++	if ( context == NULL ) return GL_FALSE;
++
++	_mesa_init_driver_functions(&functions);
++
++	/* Allocate the Mesa context */
++	if ( sharedContextPrivate )
++		shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
++	else
++		shareCtx = NULL;
++	context->glCtx = _mesa_create_context(glVisual, shareCtx,
++		                        &functions, (void *)context);
++	if ( context->glCtx == NULL ) {
++		FREE(context);
++		return GL_FALSE;
++	}
++	driContextPriv->driverPrivate = context;
++	ctx = context->glCtx;
++
++	glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
++
++	ctx->Driver.GetString = glamoGetString;
++	ctx->Driver.GetBufferSize = glamoBufferSize;
++
++	context->driContext = driContextPriv;
++	context->driScreen = sPriv;
++	context->driDrawable = NULL;
++	context->drm_fd = sPriv->fd;
++
++	/* Initialize the software rasterizer and helper modules. */
++	_swrast_CreateContext(ctx);
++	_vbo_CreateContext(ctx);
++	_tnl_CreateContext(ctx);
++	_swsetup_CreateContext(ctx);
++
++	/* Install our pipeline (see glamo_render.c) */
++	_tnl_install_pipeline(ctx, glamo_pipeline);
++
++	_swrast_allow_pixel_fog(ctx, GL_TRUE);
++	_swrast_allow_vertex_fog(ctx, GL_FALSE);
++	_tnl_allow_pixel_fog(ctx, GL_TRUE);
++	_tnl_allow_vertex_fog(ctx, GL_FALSE);
++
++	glamoInitCmdqCache(context);
++	glamoInitStateFuncs(ctx);
++	glamoInitTriFuncs(ctx);
++
++	return GL_TRUE;
++}
++
++
++void glamoDestroyContext(__DRIcontext *driContextPriv)
++{
++	glamoContextPtr context;
++
++	context = (glamoContextPtr)driContextPriv->driverPrivate;
++	assert(context != NULL);
++
++	if ( context != NULL ) {
++
++		_swsetup_DestroyContext(context->glCtx);
++		_tnl_DestroyContext(context->glCtx);
++		_vbo_DestroyContext(context->glCtx);
++		_swrast_DestroyContext(context->glCtx);
++
++		_mesa_destroy_context(context->glCtx);
++
++	}
++
++	FREE(context);
++}
++
++
++void glamo_update_renderbuffers(__DRIcontext *context,
++                                __DRIdrawable *drawable)
++{
++	unsigned int attachments[10];
++	__DRIbuffer *buffers;
++	__DRIscreen *screen;
++	int i, count;
++	struct glamo_framebuffer *draw;
++	glamoContextPtr glamo;
++	struct glamo_bo *bo;
++
++	draw = drawable->driverPrivate;
++	screen = context->driScreenPriv;
++	glamo = (glamoContextPtr)context->driverPrivate;
++	i = 0;
++	if ( draw->color_rb[0] ) {
++		attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
++	}
++	if ( draw->color_rb[1] ) {
++		attachments[i++] = __DRI_BUFFER_BACK_LEFT;
++	}
++
++	buffers = screen->dri2.loader->getBuffers(drawable,
++	                                          &drawable->w,
++	                                          &drawable->h,
++	                                          attachments, i,
++	                                          &count,
++	                                          drawable->loaderPrivate);
++	if ( buffers == NULL ) return;
++
++	/* Set one cliprect to cover the whole drawable */
++	drawable->x = 0;
++	drawable->y = 0;
++	drawable->backX = 0;
++	drawable->backY = 0;
++	drawable->numClipRects = 1;
++	drawable->pClipRects[0].x1 = 0;
++	drawable->pClipRects[0].y1 = 0;
++	drawable->pClipRects[0].x2 = drawable->w;
++	drawable->pClipRects[0].y2 = drawable->h;
++	drawable->numBackClipRects = 1;
++	drawable->pBackClipRects[0].x1 = 0;
++	drawable->pBackClipRects[0].y1 = 0;
++	drawable->pBackClipRects[0].x2 = drawable->w;
++	drawable->pBackClipRects[0].y2 = drawable->h;
++
++	/* For each attachment */
++	for ( i=0; i<count; i++ ) {
++
++		struct glamo_renderbuffer *grb;
++
++		switch ( buffers[i].attachment ) {
++		case __DRI_BUFFER_FRONT_LEFT:
++			grb = draw->color_rb[0];
++			break;
++		case __DRI_BUFFER_BACK_LEFT:
++			grb = draw->color_rb[1];
++			break;
++		case __DRI_BUFFER_DEPTH:
++			grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH);
++			break;
++		case __DRI_BUFFER_STENCIL:
++			grb = glamo_get_renderbuffer(&draw->base,
++			                                        BUFFER_STENCIL);
++			break;
++		case __DRI_BUFFER_FAKE_FRONT_LEFT:
++			grb = draw->color_rb[0];
++			break;
++		case __DRI_BUFFER_ACCUM:
++		default:
++			fprintf(stderr,
++				"Unhandled buffer attach event,"
++				" attachment type %d\n", buffers[i].attachment);
++			return;
++		}
++
++		if ( grb == NULL ) {
++			/* Don't know how to handle this type of buffer */
++			continue;
++		}
++
++		if ( grb->bo ) {
++			uint32_t name = glamo_gem_get_name(grb->bo);
++			if ( name == buffers[i].name ) {
++				/* Buffer already attached.  No action needed */
++				continue;
++			}
++		}
++
++		grb->cpp = buffers[i].cpp;
++		grb->pitch = buffers[i].pitch;
++		grb->width = drawable->w;
++		grb->height = drawable->h;
++
++		bo = glamo_bo_open(glamo->glamoScreen->bom, buffers[i].name,
++		                   0, 0, GLAMO_GEM_DOMAIN_VRAM,
++		                   buffers[i].flags);
++		if ( bo == NULL ) {
++			fprintf(stderr, "Failed to attach buffer %d\n",
++				buffers[i].name);
++		}
++
++		glamo_renderbuffer_set_bo(grb, bo);
++		glamo_bo_unref(bo);
++
++	}
++
++	driUpdateFramebufferSize(glamo->glCtx, drawable);
++}
++
++
++GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
++                           __DRIdrawable *driDrawPriv,
++                           __DRIdrawable *driReadPriv)
++{
++	struct glamo_framebuffer *draw_fb;
++	struct gl_framebuffer *read_fb;
++	glamoContextPtr glamo;
++
++	if ( driContextPriv == NULL ) {
++		_mesa_make_current(NULL, NULL, NULL);
++		return GL_TRUE;
++	}
++
++	/* The Glamo context we're switching to */
++	glamo = (glamoContextPtr)driContextPriv->driverPrivate;
++
++	glamo->driDrawable = driDrawPriv;
++
++	/* These two will probably be the same */
++	draw_fb = (struct glamo_framebuffer *)driDrawPriv->driverPrivate;
++	read_fb = (struct gl_framebuffer *)driReadPriv->driverPrivate;
++
++	glamo_update_renderbuffers(driContextPriv, driDrawPriv);
++	if (driDrawPriv != driReadPriv)
++		glamo_update_renderbuffers(driContextPriv, driReadPriv);
++
++	_mesa_make_current(glamo->glCtx, &draw_fb->base, read_fb);
++	_mesa_update_state(glamo->glCtx);
++
++	return GL_TRUE;
++}
++
++
++GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
++{
++	return GL_TRUE;
++}
++
++
++/* Convert IEEE754 32-bit float to Glamo's signed 24-bit float */
++uint32_t float7s16(GLfloat in)
++{
++	uint32_t a, b;
++	uint32_t sign, expo, mant;  /* Sign, exponent, significand */
++
++	a = *(uint32_t *)&in;
++
++	/* This is bad */
++	if ( a & 0x40000000 ) {
++		printf(stderr, "Warning: Exponent won't fit into 7 bits\n");
++	}
++
++	/* This hopefully isn't a big problem */
++	if ( a & 0x0000007f ) {
++		printf(stderr, "Warning: Precision lost in FP conversion\n");
++	}
++
++	/* Separate out the right bits */
++	mant = a & 0x007fff80;  /* Bits 7-22 (bits 0-6 are lost) */
++	expo = a & 0x3f800000;  /* Bits 23-29 (bit 30 is lost) */
++	sign = a & 0x80000000;  /* Bit 31 */
++
++	/* Shift and recombine */
++	b  = sign >> 8;  /* Fills bit 23 */
++	b |= expo >> 7;  /* Fills bits 16-22 */
++	b |= mant >> 7;  /* Fills bits 0-15 */
++
++	return b;
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
+new file mode 100644
+index 0000000..ccce29c
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_context.h
+@@ -0,0 +1,106 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_context.h (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_CONTEXT_H
++#define __GLAMO_CONTEXT_H
++
++
++#include "dri_util.h"
++#include "utils.h"
++#include "tnl/t_vertex.h"
++
++#include "glamo_screen.h"
++
++
++typedef struct glamo_context glamoContext;
++typedef struct glamo_context *glamoContextPtr;
++
++struct glamo_context {
++
++	GLcontext *glCtx;                  /* Must be first in this structure */
++
++	int drm_fd;                        /* DRM fd */
++
++	__DRIcontext  *driContext;  /* DRI context */
++	__DRIscreen   *driScreen;   /* DRI screen */
++	__DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */
++
++	glamoScreenPtr glamoScreen;        /* Screen private DRI data */
++
++	driOptionCache optionCache;
++
++	uint16_t *cmdq_drm;                /* Command queue cache */
++	uint16_t cmd_burst_base;
++	int cmdq_drm_used;
++	int cmdq_drm_size;
++	int cmdq_obj_used;
++	uint32_t *cmdq_objs;
++	unsigned int *cmdq_obj_pos;
++
++	/* Information about the current primitive */
++	struct {
++		GLuint id;
++		uint32_t primitive;	/* Current hardware primitive type */
++		struct glamo_bo *vb_bo;
++		uint8_t *vb;
++		unsigned int start_offset; /* Byte offset of start */
++		unsigned int current_offset; /* Byte offset of next vertex */
++		unsigned int count;	/* Number of vertices */
++	} prim;
++
++	/* Current vertex format and attributes */
++	int vertex_size;
++	struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
++
++	/* State */
++	GLuint new_state;      /* State which must be updated */
++	uint16_t col_clear;
++
++};
++
++#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
++
++#define TAG(x) glamo##x
++#include "tnl_dd/t_dd_vertex.h"
++#undef TAG
++
++extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
++                                    __DRIcontext *driContextPriv,
++                                    void *sharedContextPrivate);
++extern void glamoDestroyContext(__DRIcontext *dcp);
++extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
++                                  __DRIdrawable *driDrawPriv,
++                                  __DRIdrawable *driReadPriv);
++extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
++extern void glamo_update_renderbuffers(__DRIcontext *context,
++                                       __DRIdrawable *drawable);
++
++#define GLAMO_PACKCOLOR565(r, g, b) \
++	((((r) & 0xf8) << 8)        \
++	| (((g) & 0xfc) << 3)       \
++	| (((b) & 0xf8) >> 3))
++
++extern uint32_t float7s16(GLfloat in);
++
++#endif   /* __GLAMO_CONTEXT_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c
+new file mode 100644
+index 0000000..c866d21
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c
+@@ -0,0 +1,130 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on radeon_fbo.c (c) 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"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "main/imports.h"
++#include "main/macros.h"
++#include "main/mtypes.h"
++#include "main/formats.h"
++#include "main/fbobject.h"
++#include "main/framebuffer.h"
++#include "main/renderbuffer.h"
++#include "main/context.h"
++#include "dri_util.h"
++
++/* This comes from libdrm_glamo */
++#include <glamo_bo.h>
++
++#include "glamo_fbo.h"
++
++
++static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb)
++{
++   struct glamo_renderbuffer *grb = glamo_renderbuffer(rb);
++
++   ASSERT(grb);
++
++   if ( grb && grb->bo ) {
++      glamo_bo_unref(grb->bo);
++   }
++   _mesa_free(grb);
++}
++
++
++static void *glamo_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb,
++                               GLint x, GLint y)
++{
++   return NULL;   /* Can't be directly addressed */
++}
++
++
++/* Called for each hardware renderbuffer when a _window_ is resized.
++ * Just update fields.
++ * Not used for user-created renderbuffers!
++ */
++static GLboolean glamo_alloc_window_storage(GLcontext *ctx,
++                                            struct gl_renderbuffer *rb,
++                                            GLenum internalFormat,
++                                            GLuint width, GLuint height)
++{
++   ASSERT(rb->Name == 0);
++   rb->Width = width;
++   rb->Height = height;
++   rb->Format = internalFormat;
++   return GL_TRUE;
++}
++
++
++/* Create a buffer, such as a colour or depth buffer */
++struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
++                                              __DRIdrawable *driDrawPriv)
++{
++   struct glamo_renderbuffer *grb;
++
++   grb = CALLOC_STRUCT(glamo_renderbuffer);
++   if ( !grb ) return NULL;
++
++   _mesa_init_renderbuffer(&grb->base, 0);
++   grb->base.ClassID = GLAMO_RB_CLASS;
++
++   switch (format) {
++      case GL_RGB5:
++         grb->base.Format = MESA_FORMAT_RGB565;
++         grb->base._BaseFormat = GL_RGB;
++
++         grb->base.DataType = GL_UNSIGNED_BYTE;
++         break;
++      case GL_DEPTH_COMPONENT16:
++         grb->base.DataType = GL_UNSIGNED_SHORT;
++	 grb->base._BaseFormat = GL_DEPTH_COMPONENT;
++         break;
++      default:
++         fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
++         _mesa_delete_renderbuffer(&grb->base);
++         return NULL;
++   }
++
++   grb->dPriv = driDrawPriv;
++   grb->base.InternalFormat = format;
++
++   grb->base.Delete = glamo_delete_renderbuffer;
++   grb->base.AllocStorage = glamo_alloc_window_storage;
++   grb->base.GetPointer = glamo_get_pointer;
++
++   return grb;
++}
++
++
++void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
++                               struct glamo_bo *bo)
++{
++  struct glamo_bo *old;
++  old = grb->bo;
++  grb->bo = bo;
++  glamo_bo_ref(bo);
++  if ( old ) glamo_bo_unref(old);
++}
++
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h
+new file mode 100644
+index 0000000..48210dd
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h
+@@ -0,0 +1,77 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_FBO_H
++#define __GLAMO_FBO_H
++
++
++#include "main/mtypes.h"
++#include "dri_util.h"
++
++
++/* This is just a marker so we can tell a Glamo renderbuffer from a Mesa one */
++#define GLAMO_RB_CLASS (0xdeadbeef)
++
++
++struct glamo_renderbuffer
++{
++	struct gl_renderbuffer base;   /* Must be first */
++	struct glamo_bo *bo;
++	unsigned int cpp;
++	unsigned int pitch;
++	unsigned int width;
++	unsigned int height;
++
++	__DRIdrawable *dPriv;
++};
++
++
++struct glamo_framebuffer
++{
++	struct gl_framebuffer base;
++	struct glamo_renderbuffer *color_rb[2];
++};
++
++
++/* This is just a small wrapper function to return NULL if the gl_renderbuffer
++ * is not a glamo_renderbuffer */
++static inline struct glamo_renderbuffer
++                                 *glamo_renderbuffer(struct gl_renderbuffer *rb)
++{
++	struct glamo_renderbuffer *grb = (struct glamo_renderbuffer *)rb;
++	if ( grb && grb->base.ClassID == GLAMO_RB_CLASS )
++		return grb;
++	else
++		return NULL;
++}
++
++
++extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
++                                             __DRIdrawable *driDrawPriv);
++
++extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
++                               struct glamo_bo *bo);
++
++#endif   /* __GLAMO_FBO_H */
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_regs.h b/src/mesa/drivers/dri/glamo/glamo_regs.h
+new file mode 100644
+index 0000000..02b2294
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_regs.h
+@@ -0,0 +1,174 @@
++#ifndef _GLAMO_REGS_H
++#define _GLAMO_REGS_H
++
++/* Smedia Glamo 336x/337x driver
++ *
++ * (C) 2007 by OpenMoko, Inc.
++ * Author: Harald Welte <laforge@openmoko.org>
++ * All rights reserved.
++ *
++ * Modified for Glamo Mesa driver by Thomas White <taw@bitwiz.org.uk>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++enum glamo_regster_offsets {
++	GLAMO_REGOFS_GENERIC	= 0x0000,
++	GLAMO_REGOFS_HOSTBUS	= 0x0200,
++	GLAMO_REGOFS_MEMORY	= 0x0300,
++	GLAMO_REGOFS_VIDCAP	= 0x0400,
++	GLAMO_REGOFS_ISP	= 0x0500,
++	GLAMO_REGOFS_JPEG	= 0x0800,
++	GLAMO_REGOFS_MPEG	= 0x0c00,
++	GLAMO_REGOFS_LCD	= 0x1100,
++	GLAMO_REGOFS_MMC	= 0x1400,
++	GLAMO_REGOFS_MPROC0	= 0x1500,
++	GLAMO_REGOFS_MPROC1	= 0x1580,
++	GLAMO_REGOFS_CMDQUEUE	= 0x1600,
++	GLAMO_REGOFS_RISC	= 0x1680,
++	GLAMO_REGOFS_2D		= 0x1700,
++	GLAMO_REGOFS_3D		= 0x1b00,
++};
++
++
++#define REG_MPEG(x)           (GLAMO_REGOFS_MPEG+(x))
++
++enum glamo_register_mpeg {
++      //
++      GLAMO_REG_MPEG_DC_ADDRL         = REG_MPEG(0x3c),
++      GLAMO_REG_MPEG_DC_ADDRH         = REG_MPEG(0x3e),
++      GLAMO_REG_MPEG_AC_ADDRL         = REG_MPEG(0x40),
++      GLAMO_REG_MPEG_AC_ADDRH         = REG_MPEG(0x42),
++      //
++      GLAMO_REG_MPEG_SAFE_1           = REG_MPEG(0x60),
++      GLAMO_REG_MPEG_SAFE_2           = REG_MPEG(0x62),
++      GLAMO_REG_MPEG_SAFE_3           = REG_MPEG(0x64),
++      //
++      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRL = REG_MPEG(0x6e),
++      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRH = REG_MPEG(0x70),
++      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRL = REG_MPEG(0x72),
++      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRH = REG_MPEG(0x74),
++      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRL = REG_MPEG(0x76),
++      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRH = REG_MPEG(0x78),
++      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRL = REG_MPEG(0x7a),
++      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRH = REG_MPEG(0x7c),
++      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRL = REG_MPEG(0x7e),
++      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRH = REG_MPEG(0x80),
++      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRL = REG_MPEG(0x82),
++      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRH = REG_MPEG(0x84),
++      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRL = REG_MPEG(0x86),
++      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRH = REG_MPEG(0x88),
++      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRL = REG_MPEG(0x8a),
++      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRH = REG_MPEG(0x8c),
++      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRL = REG_MPEG(0x8e),
++      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRH = REG_MPEG(0x90),
++      GLAMO_REG_MPEG_DEC_WIDTH        = REG_MPEG(0x92),
++      GLAMO_REG_MPEG_DEC_HEIGHT       = REG_MPEG(0x94),
++      GLAMO_REG_MPEG_SPECIAL          = REG_MPEG(0x96),
++      GLAMO_REG_MPEG_DEC_IN_ADDRL     = REG_MPEG(0x98),
++      GLAMO_REG_MPEG_DEC_IN_ADDRH     = REG_MPEG(0x9a),
++      //
++      GLAMO_REG_MPEG_DEBLK_THRESHOLD  = REG_MPEG(0xc0),
++      //
++      GLAMO_REG_MPEG_DEC_STATUS       = REG_MPEG(0xc8),
++      GLAMO_REG_MPEG_DEC_RB0          = REG_MPEG(0xca),
++      GLAMO_REG_MPEG_DEC_RB1          = REG_MPEG(0xcc),
++};
++
++
++#define REG_2D(x)		(GLAMO_REGOFS_2D+(x))
++
++enum glamo_register_2d {
++	GLAMO_REG_2D_SRC_ADDRL		= REG_2D(0x00),
++	GLAMO_REG_2D_SRC_ADDRH		= REG_2D(0x02),
++	GLAMO_REG_2D_SRC_PITCH		= REG_2D(0x04),
++	GLAMO_REG_2D_SRC_X		= REG_2D(0x06),
++	GLAMO_REG_2D_SRC_Y		= REG_2D(0x08),
++	GLAMO_REG_2D_DST_X		= REG_2D(0x0a),
++	GLAMO_REG_2D_DST_Y		= REG_2D(0x0c),
++	GLAMO_REG_2D_DST_ADDRL		= REG_2D(0x0e),
++	GLAMO_REG_2D_DST_ADDRH		= REG_2D(0x10),
++	GLAMO_REG_2D_DST_PITCH		= REG_2D(0x12),
++	GLAMO_REG_2D_DST_HEIGHT		= REG_2D(0x14),
++	GLAMO_REG_2D_RECT_WIDTH		= REG_2D(0x16),
++	GLAMO_REG_2D_RECT_HEIGHT	= REG_2D(0x18),
++	GLAMO_REG_2D_PAT_ADDRL		= REG_2D(0x1a),
++	GLAMO_REG_2D_PAT_ADDRH		= REG_2D(0x1c),
++	GLAMO_REG_2D_PAT_FG		= REG_2D(0x1e),
++	GLAMO_REG_2D_PAT_BG		= REG_2D(0x20),
++	GLAMO_REG_2D_SRC_FG		= REG_2D(0x22),
++	GLAMO_REG_2D_SRC_BG		= REG_2D(0x24),
++	GLAMO_REG_2D_MASK1		= REG_2D(0x26),
++	GLAMO_REG_2D_MASK2		= REG_2D(0x28),
++	GLAMO_REG_2D_MASK3		= REG_2D(0x2a),
++	GLAMO_REG_2D_MASK4		= REG_2D(0x2c),
++	GLAMO_REG_2D_ROT_X		= REG_2D(0x2e),
++	GLAMO_REG_2D_ROT_Y		= REG_2D(0x30),
++	GLAMO_REG_2D_LEFT_CLIP		= REG_2D(0x32),
++	GLAMO_REG_2D_TOP_CLIP		= REG_2D(0x34),
++	GLAMO_REG_2D_RIGHT_CLIP		= REG_2D(0x36),
++	GLAMO_REG_2D_BOTTOM_CLIP	= REG_2D(0x38),
++	GLAMO_REG_2D_COMMAND1		= REG_2D(0x3A),
++	GLAMO_REG_2D_COMMAND2		= REG_2D(0x3C),
++	GLAMO_REG_2D_COMMAND3		= REG_2D(0x3E),
++	GLAMO_REG_2D_SAFE		= REG_2D(0x40),
++	GLAMO_REG_2D_STATUS		= REG_2D(0x42),
++	GLAMO_REG_2D_ID1		= REG_2D(0x44),
++	GLAMO_REG_2D_ID2		= REG_2D(0x46),
++	GLAMO_REG_2D_ID3		= REG_2D(0x48),
++};
++
++
++/* No offset this time */
++#define REG_3D(x)		(x)
++
++enum glamo_register_3d
++{
++	/* Fire the engine */
++	G3D_FIRE			= REG_3D(0x2058),
++
++	/* Streams of vertex/colour/normal/texcoord data */
++	G3D_ACTIVE_STREAMS		= REG_3D(0x1f00),
++	G3D_LAST_STREAM__VCOLFMT	= REG_3D(0x2030),
++	G3D_STREAM_MODE_0		= REG_3D(0x1f10),
++	G3D_STREAM_BASE_0		= REG_3D(0x1f14),
++	G3D_STREAM_MODE_1		= REG_3D(0x1f18),
++	G3D_STREAM_BASE_1		= REG_3D(0x1f1c),
++	G3D_STREAM_MODE_2		= REG_3D(0x1f20),
++	G3D_STREAM_BASE_2		= REG_3D(0x1f24),
++	G3D_STREAM_MODE_3		= REG_3D(0x1f28),
++	G3D_STREAM_BASE_3		= REG_3D(0x1f2c),
++	G3D_STREAM_MODE_4		= REG_3D(0x1f30),
++	G3D_STREAM_BASE_4		= REG_3D(0x1f34),
++	G3D_STREAM_MODE_5		= REG_3D(0x1f38),
++	G3D_STREAM_BASE_5		= REG_3D(0x1f3c),
++	G3D_STREAM_MODE_6		= REG_3D(0x1f40),
++	G3D_STREAM_BASE_6		= REG_3D(0x1f44),
++	G3D_STREAM_MODE_7		= REG_3D(0x1f48),
++	G3D_STREAM_BASE_7		= REG_3D(0x1f4c),
++
++	/* Modelview*projection matrix */
++	G3D_MATRIX_MVP			= REG_3D(0x26a0), /* .. 0x27df */
++
++	/* Modelview matrix */
++	G3D_MATRIX_MV			= REG_3D(0x26e0), /* .. 0x270f */
++
++	/* Inverse MVP, 3x3 only */
++	G3D_MATRIX_IMVP			= REG_3D(0x2710), /* .. 0x2733 */
++
++};
++
++#endif /* _GLAMO_REGS_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c
+new file mode 100644
+index 0000000..fd52418
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_render.c
+@@ -0,0 +1,230 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS 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.
++ *
++ *
++ * Based on intel_render.c, to which the following notice applies:
++ *
++ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS 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.
++ *
++ */
++
++
++/*
++ * Render unclipped vertex buffers by emitting vertices directly to
++ * dma buffers.  Use strip/fan hardware acceleration where possible.
++ *
++ */
++#include "main/glheader.h"
++#include "main/context.h"
++#include "main/macros.h"
++#include "main/imports.h"
++#include "main/mtypes.h"
++#include "main/enums.h"
++
++#include "tnl/t_context.h"
++#include "tnl/t_vertex.h"
++#include "tnl/t_pipeline.h"
++
++#include "glamo_context.h"
++#include "glamo_tris.h"
++#include "glamo_regs.h"
++
++/*
++ * Render unclipped vertex buffers by emitting vertices directly to
++ * VRAM buffers.  Use strip/fan hardware primitives where possible.
++ * Try to simulate missing primitives with indexed vertices.
++ */
++#define HAVE_POINTS      1
++#define HAVE_LINES       1
++#define HAVE_LINE_STRIPS 0
++#define HAVE_TRIANGLES   1
++#define HAVE_TRI_STRIPS  0
++#define HAVE_TRI_STRIP_1 0
++#define HAVE_TRI_FANS    0
++#define HAVE_POLYGONS    0
++#define HAVE_QUADS       0
++#define HAVE_QUAD_STRIPS 0
++#define HAVE_ELTS        0
++
++
++static void glamoFlushPrim(struct glamo_context *gCtx)
++{
++	printf("glamoFlushPrim: %i vertices, %i %i\n", gCtx->prim.count,
++	gCtx->prim.start_offset, gCtx->prim.current_offset);
++
++	if ( gCtx->prim.vb_bo == NULL ) return;
++
++	/* Upload to hardware */
++	glamo_bo_subdata(gCtx->prim.vb_bo, 0, gCtx->prim.current_offset,
++	                 gCtx->prim.vb);
++
++	/* Dispatch to the hardware */
++	glamoDRMStartBurst(gCtx, G3D_STREAM_MODE_0);
++	glamoDRMAddData(gCtx, 0x000f0300, 4);
++	glamoDRMAddBO(gCtx, gCtx->prim.vb_bo);
++	glamoDRMDispatch(gCtx);
++
++	/* Please use a new BO for the next buffer */
++	gCtx->prim.vb_bo = NULL;
++
++	/* Continue from new start */
++	gCtx->prim.start_offset = gCtx->prim.current_offset;
++}
++
++
++static inline GLuint glamoGetVBMax(struct glamo_context *gCtx)
++{
++	return GLAMO_VB_SIZE / gCtx->vertex_size;
++}
++
++
++static inline GLuint glamoGetCurrentMax(struct glamo_context *gCtx)
++{
++	/* How many more vertices can be accommodated?
++	 * Each vertex takes up 4x 32-bit fixed point values */
++	return (GLAMO_VB_SIZE - gCtx->prim.current_offset) / gCtx->vertex_size;
++}
++
++
++#define LOCAL_VARS \
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++#define INIT(prim)
++
++#define FLUSH() glamoFlushPrim(gCtx)
++
++#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx)
++#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx)
++
++#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr)
++
++#define EMIT_VERTS(ctx, j, nr, buf) \
++	_tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
++
++#define TAG(x) glamo_##x
++#include "tnl_dd/t_dd_dmatmp.h"
++
++
++/**********************************************************************/
++/*                          Render pipeline stage                     */
++/**********************************************************************/
++
++static void glamoFireEngine(struct glamo_context *gCtx)
++{
++	glamoDRMStartBurst(gCtx, G3D_FIRE);
++	glamoDRMAddData(gCtx, 0, 2);  /* Fire! */
++	glamoDRMDispatch(gCtx);
++}
++
++
++static GLboolean glamoRunRender(GLcontext *ctx,
++                                struct tnl_pipeline_stage *stage)
++{
++	TNLcontext *tnl = TNL_CONTEXT(ctx);
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	struct vertex_buffer *VB = &tnl->vb;
++	GLuint i;
++
++	printf("glamoRunRender\n");
++
++	/* Don't handle clipping */
++	if ( !glamo_validate_render(ctx, VB) ) {
++		return GL_TRUE; /* Failed */
++	}
++
++	/* Validate GPU state */
++	if ( gCtx->new_state ) {
++		if ( !glamoValidateState(ctx, gCtx->new_state) ) {
++			printf("Couldn't validate state...\n");
++		}
++	} /* else nothing to update */
++
++	tnl->clipspace.new_inputs |= VERT_BIT_POS;
++
++	tnl->Driver.Render.Start(ctx);
++
++	for ( i=0; i<VB->PrimitiveCount; i++ ) {
++
++		GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
++		GLuint start = VB->Primitive[i].start;
++		GLuint length = VB->Primitive[i].count;
++
++		if (!length) continue;
++
++		glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start,
++                                                     start + length, prim);
++
++	}
++
++	tnl->Driver.Render.Finish(ctx);
++
++	glamoFireEngine(gCtx);
++
++	return GL_FALSE;  /* Ok */
++}
++
++
++static const struct tnl_pipeline_stage _glamo_render_stage = {
++	"glamo render",
++	NULL,
++	NULL,
++	NULL,
++	NULL,
++	glamoRunRender
++};
++
++
++const struct tnl_pipeline_stage *glamo_pipeline[] = {
++	&_tnl_vertex_transform_stage,
++	&_tnl_vertex_cull_stage,
++	&_tnl_normal_transform_stage,
++	&_tnl_lighting_stage,
++	&_tnl_fog_coordinate_stage,
++	&_tnl_texgen_stage,
++	&_tnl_texture_transform_stage,
++	&_tnl_point_attenuation_stage,
++	&_tnl_vertex_program_stage,
++	&_glamo_render_stage,        /* ADD: unclipped rastersetup-to-dma */
++	&_tnl_render_stage,
++	0,
++};
+diff --git a/src/mesa/drivers/dri/glamo/glamo_render.h b/src/mesa/drivers/dri/glamo/glamo_render.h
+new file mode 100644
+index 0000000..99c36a8
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_render.h
+@@ -0,0 +1,31 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_RENDER_H
++#define __GLAMO_RENDER_H
++
++#include "main/mtypes.h"
++
++extern const struct tnl_pipeline_stage *glamo_pipeline[];
++
++#endif   /* __GLAMO_RENDER_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
+new file mode 100644
+index 0000000..39148f3
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
+@@ -0,0 +1,250 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_screen.c (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "dri_util.h"
++#include "utils.h"
++#include "xmlconfig.h"
++#include "GL/internal/dri_interface.h"
++#include "main/framebuffer.h"
++#include "main/renderbuffer.h"
++
++#include "glamo_screen.h"
++#include "glamo_context.h"
++#include "glamo_fbo.h"
++
++/* This comes from libdrm_glamo */
++#include <glamo_bo_gem.h>
++
++
++static int glamoInitDriver(__DRIscreen *psp)
++{
++   return 0;
++}
++
++
++static glamoScreenPtr glamoCreateScreen(__DRIscreen *sPriv)
++{
++   glamoScreenPtr glamoScreen;
++
++   /* Allocate the private area */
++   glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen));
++   if ( glamoScreen == NULL )
++      return NULL;
++
++   glamoScreen->driScreen = sPriv;
++
++   /* This is our link to the kernel's memory manager, via libdrm */
++   glamoScreen->bom = glamo_bo_manager_gem_ctor(sPriv->fd);
++
++   return glamoScreen;
++}
++
++
++static void glamoDestroyScreen(__DRIscreen *sPriv)
++{
++   glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private;
++
++   if ( glamoScreen == NULL )
++      return;
++
++   FREE(glamoScreen);
++   sPriv->private = NULL;
++}
++
++
++static const __DRIconfig **glamoInitScreen(__DRIscreen *sPriv)
++{
++   __DRIconfig **configs;
++   uint8_t depth_bits_array[2];
++   uint8_t stencil_bits_array[2];
++   uint8_t msaa_samples_array[1];
++   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
++
++   /* Driver initialisation */
++   if ( glamoInitDriver(sPriv) ) {
++      return NULL;
++   }
++
++   /* Screen-specific initialisation */
++   sPriv->private = glamoCreateScreen(sPriv);
++   if ( !sPriv->private ) {
++      glamoDestroyScreen(sPriv);
++      return NULL;
++   }
++
++   depth_bits_array[0] = 0;
++   stencil_bits_array[0] = 0;
++   depth_bits_array[1] = 16;
++   stencil_bits_array[1] = 0;
++   msaa_samples_array[0] = 0;
++
++   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
++                           depth_bits_array, stencil_bits_array, 2,
++                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
++
++   if ( configs == NULL ) {
++      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
++      return NULL;
++   }
++
++   return (const __DRIconfig **)configs;
++}
++
++
++static const __DRIconfig **glamoInitScreen2(__DRIscreen *sPriv)
++{
++   __DRIconfig **configs;
++   uint8_t depth_bits_array[2];
++   uint8_t stencil_bits_array[2];
++   uint8_t msaa_samples_array[1];
++   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
++
++   /* Driver initialisation */
++   if ( glamoInitDriver(sPriv) ) {
++      return NULL;
++   }
++
++   /* Screen-specific initialisation */
++   sPriv->private = glamoCreateScreen(sPriv);
++   if ( !sPriv->private ) {
++      glamoDestroyScreen(sPriv);
++      return NULL;
++   }
++
++   depth_bits_array[0] = 0;
++   stencil_bits_array[0] = 0;
++   depth_bits_array[1] = 16;
++   stencil_bits_array[1] = 0;
++   msaa_samples_array[0] = 0;
++
++   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
++                           depth_bits_array, stencil_bits_array, 2,
++                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
++
++   if ( configs == NULL ) {
++      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
++      return NULL;
++   }
++
++   return (const __DRIconfig **)configs;
++}
++
++
++/* Allocate buffers for a context.  This is where the fun starts... */
++static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
++                                   __DRIdrawable *driDrawPriv,
++                                   const __GLcontextModes *mesaVis,
++                                   GLboolean isPixmap)
++{
++   struct glamo_framebuffer *gfb;
++   GLenum rgbFormat;
++
++   if ( isPixmap ) return GL_FALSE; /* not implemented */
++
++   gfb = CALLOC_STRUCT(glamo_framebuffer);
++   if ( !gfb ) return GL_FALSE;
++
++   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
++
++   /* we only support this one format at the moment */
++   rgbFormat = GL_RGB5;
++
++   /* Front color renderbuffer */
++   gfb->color_rb[0] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
++   _mesa_add_renderbuffer(&gfb->base, BUFFER_FRONT_LEFT,
++                          &gfb->color_rb[0]->base);
++
++   /* Back color renderbuffer, if requested */
++   if ( mesaVis->doubleBufferMode ) {
++      gfb->color_rb[1] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
++      _mesa_add_renderbuffer(&gfb->base, BUFFER_BACK_LEFT,
++                             &gfb->color_rb[1]->base);
++   }
++
++   if ( mesaVis->depthBits == 16 ) {
++      struct glamo_renderbuffer *depth;
++      depth = glamo_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
++      _mesa_add_renderbuffer(&gfb->base, BUFFER_DEPTH, &depth->base);
++   }
++
++   /* Add software renderbuffers for the things we can't support in hardware */
++   _mesa_add_soft_renderbuffers(&gfb->base,
++      GL_FALSE,  /* color */
++      GL_FALSE,  /* depth */
++      mesaVis->stencilBits > 0,   /* stencil, if required */
++      mesaVis->accumRedBits > 0,  /* accum, if required */
++      GL_FALSE,  /* alpha */
++      GL_FALSE   /* aux */
++   );
++   driDrawPriv->driverPrivate = (void *)gfb;
++
++   return (driDrawPriv->driverPrivate != NULL);
++}
++
++
++static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
++{
++}
++
++
++static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
++{
++   printf("glamoSwapBuffers\n"); fflush(stdout);
++}
++
++
++/*
++ *  Mesa entry points
++ *
++ *  See src/mesa/drivers/dri/common/dri_util.h for information about these
++ */
++const struct __DriverAPIRec driDriverAPI = {
++   .InitScreen      = glamoInitScreen,
++   .DestroyScreen   = glamoDestroyScreen,
++   .CreateContext   = glamoCreateContext,
++   .DestroyContext  = glamoDestroyContext,
++   .CreateBuffer    = glamoCreateBuffer,
++   .DestroyBuffer   = glamoDestroyBuffer,
++   .SwapBuffers     = glamoSwapBuffers,
++   .MakeCurrent     = glamoMakeCurrent,
++   .UnbindContext   = glamoUnbindContext,
++   .GetSwapInfo     = NULL,   /* Not used */
++   .WaitForMSC      = NULL,
++   .WaitForSBC      = NULL,
++   .SwapBuffersMSC  = NULL,
++   .CopySubBuffer   = NULL,
++   .GetDrawableMSC  = NULL,   /* Not used */
++   .InitScreen2     = glamoInitScreen2,    /* For DRI2 */
++};
++
++/* This is the table of extensions that the loader will dlsym() for. */
++PUBLIC const __DRIextension *__driDriverExtensions[] = {
++    &driCoreExtension.base,
++    &driLegacyExtension.base,
++    &driDRI2Extension.base,
++    NULL
++};
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h
+new file mode 100644
+index 0000000..3f2eb5f
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_screen.h
+@@ -0,0 +1,44 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_screen.h (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_SCREEN_H
++#define __GLAMO_SCREEN_H
++
++#include "xmlconfig.h"
++#include "dri_util.h"
++
++#include <glamo_bo_gem.h>
++
++typedef struct {
++
++   __DRIscreen *driScreen;
++   driOptionCache optionCache;
++
++   struct glamo_bo_manager *bom;
++
++} glamoScreenRec, *glamoScreenPtr;
++
++#endif   /* __GLAMO_SCREEN_H */
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c
+new file mode 100644
+index 0000000..4046c24
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_state.c
+@@ -0,0 +1,304 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009-2010 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_state.c (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS 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.
++ *
++ *
++ * Also partially based on intel_fbo.c, to which the following notice applies:
++ *
++ * Copyright 2006 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++#include "main/context.h"
++#include "main/framebuffer.h"
++#include "main/api_arrayelt.h"
++#include "swrast/swrast.h"
++#include "swrast_setup/swrast_setup.h"
++#include "tnl/tnl.h"
++
++#include "glamo_fbo.h"
++#include "glamo_state.h"
++#include "glamo_context.h"
++#include "glamo_cmdq.h"
++#include "glamo_regs.h"
++
++
++static void glamoResizeBuffers(GLcontext *ctx, struct gl_framebuffer *fb,
++                               GLuint width, GLuint height)
++{
++	struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb;
++	int i;
++
++	_mesa_resize_framebuffer(ctx, fb, width, height);
++
++	fb->Initialized = GL_TRUE; /* XXX remove someday */
++
++	if (fb->Name != 0) {
++		return;
++	}
++
++	/* Make sure all window system renderbuffers are up to date */
++	for (i = 0; i < 2; i++) {
++		struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base;
++
++		/* only resize if size is changing */
++		if (rb && (rb->Width != width || rb->Height != height)) {
++			rb->AllocStorage(ctx, rb, rb->InternalFormat,
++		                         width, height);
++		}
++	}
++}
++
++
++static void glamoClear(GLcontext *ctx, GLbitfield mask)
++{
++	glamoContext *gCtx;
++	struct gl_framebuffer *fb;
++	int i;
++
++	gCtx = GLAMO_CONTEXT(ctx);
++	fb = ctx->DrawBuffer;
++
++	printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0],
++	       ctx->Color.ClearColor[1], ctx->Color.ClearColor[2],
++	       ctx->Color.ClearColor[3]); fflush(stdout);
++
++	for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
++
++		struct glamo_renderbuffer *grb;
++
++		grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]);
++
++		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_DST_X);
++		glamoDRMAddData(gCtx, fb->_Xmin, 2);           /* dest X */
++		glamoDRMAddData(gCtx, fb->_Ymin, 2);           /* dest Y */
++		glamoDRMAddBO(gCtx, grb->bo);                  /* dest L/H */
++		glamoDRMAddData(gCtx, grb->pitch & 0x7ff, 2);  /* dest pitch */
++		glamoDRMAddData(gCtx, grb->height, 2);         /* dest height */
++		glamoDRMAddData(gCtx, fb->_Xmax-fb->_Xmin, 2); /* width */
++		glamoDRMAddData(gCtx, fb->_Ymax-fb->_Ymin, 2); /* height */
++		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt L */
++		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt H */
++		glamoDRMAddData(gCtx, gCtx->col_clear, 2);     /* FG colour */
++		glamoDRMDispatch(gCtx);
++
++		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_COMMAND1);
++		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 1 */
++		glamoDRMAddData(gCtx, 0xf0 << 8, 2); /* Cmd param 2 */
++		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 3 */
++		glamoDRMDispatch(gCtx);
++
++	}
++}
++
++
++static void glamoClearColor(GLcontext *ctx, const GLfloat color[4])
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	GLubyte col_byte[4];
++
++	printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2],
++	       color[3]); fflush(stdout);
++
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]);
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]);
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]);
++	CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]);
++
++	gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1],
++	                                     col_byte[2]);
++}
++
++
++static void glamoShadeModel(GLcontext *ctx, GLenum mode)
++{
++	printf("glamoShadeModel\n"); fflush(stdout);
++}
++
++
++static void glamoViewport(GLcontext *ctx, GLint x, GLint y,
++                          GLsizei width, GLsizei height )
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	__DRIcontext *driContext = gCtx->driContext;
++	void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
++			 GLsizei w, GLsizei h);
++
++	if ( !driContext->driScreenPriv->dri2.enabled ) return;
++
++	/* TODO: Flush before fiddling with fake front buffer */
++
++	if ( ctx->DrawBuffer->Name == 0 ) {
++
++		glamo_update_renderbuffers(driContext,
++		                           driContext->driDrawablePriv);
++		if ( driContext->driDrawablePriv
++		                              != driContext->driReadablePriv ) {
++			glamo_update_renderbuffers(driContext,
++				                   driContext->driReadablePriv);
++		}
++
++	}
++
++	old_viewport = ctx->Driver.Viewport;
++	ctx->Driver.Viewport = NULL;
++	gCtx->driDrawable = driContext->driDrawablePriv;
++	ctx->Driver.Viewport = old_viewport;
++}
++
++
++static void glamoUploadMatrix(struct glamo_context *gCtx, uint16_t mreg,
++                              GLfloat *matrix)
++{
++	int i;
++	char *type;
++
++	switch ( mreg ) {
++	case G3D_MATRIX_MVP :
++		type = "MVP"; break;
++	case G3D_MATRIX_MV :
++		type = "MV"; break;
++	case G3D_MATRIX_IMVP :
++		type = "inverse MVP"; break;
++	default :
++		type = "unknown"; break;
++	}
++	printf("Uploading %s matrix...\n", type);
++
++	glamoDRMStartBurst(gCtx, mreg);
++	if ( mreg != G3D_MATRIX_IMVP ) {
++		for ( i=0; i<16; i++ ) {
++			glamoDRMAddData(gCtx, float7s16(matrix[i]), 4);
++		}
++	} else {
++		/* Normal matrix needs special treatment */
++		for ( i=0; i<3; i++ ) {
++			glamoDRMAddData(gCtx, float7s16(matrix[4*i]), 4);
++			glamoDRMAddData(gCtx, float7s16(matrix[4*i+1]), 4);
++			glamoDRMAddData(gCtx, float7s16(matrix[4*i+2]), 4);
++		}
++	}
++	glamoDRMDispatch(gCtx);
++}
++
++
++GLboolean glamoValidateState(GLcontext *ctx, GLuint new_state)
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++	if ( new_state & (_NEW_MODELVIEW|_NEW_PROJECTION) ) {
++
++		glamoUploadMatrix(gCtx, G3D_MATRIX_MVP,
++		                  ctx->_ModelProjectMatrix.m);
++
++		/* FIXME: The following two aren't needed unless lighting
++		 * is in use... */
++		glamoUploadMatrix(gCtx, G3D_MATRIX_MV,
++		                  ctx->ModelviewMatrixStack.Top->m);
++		_math_matrix_alloc_inv(&(ctx->_ModelProjectMatrix));
++		_math_matrix_analyse(&(ctx->_ModelProjectMatrix));
++		glamoUploadMatrix(gCtx, G3D_MATRIX_IMVP,
++		                  ctx->_ModelProjectMatrix.inv);
++	}
++
++	gCtx->new_state = 0;
++	return GL_TRUE;
++}
++
++
++static void glamoUpdateState(GLcontext *ctx, GLbitfield new_state)
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++	printf("glamoUpdateState\n");
++
++	_swrast_InvalidateState(ctx, new_state);
++	_swsetup_InvalidateState(ctx, new_state);
++	_vbo_InvalidateState(ctx, new_state);
++	_tnl_InvalidateState(ctx, new_state);
++	_ae_invalidate_state(ctx, new_state);
++
++	/* Make a note that some state has changed,
++	 * so that it can be sent to the GPU later. */
++	gCtx->new_state |= new_state;
++}
++
++
++static void glamoFlush(GLcontext *ctx)
++{
++	printf("glamoFlush\n");
++}
++
++
++void glamoInitStateFuncs(GLcontext *ctx)
++{
++	ctx->Driver.UpdateState       = glamoUpdateState;
++	ctx->Driver.Clear             = glamoClear;
++	ctx->Driver.ClearColor        = glamoClearColor;
++	ctx->Driver.ClearDepth        = NULL;
++	ctx->Driver.ClearStencil      = NULL;
++	ctx->Driver.AlphaFunc         = NULL;
++	ctx->Driver.BlendFuncSeparate = NULL;
++	ctx->Driver.ColorMask         = NULL;
++	ctx->Driver.CullFace          = NULL;
++	ctx->Driver.DepthMask         = NULL;
++	ctx->Driver.DepthFunc         = NULL;
++	ctx->Driver.DepthRange        = NULL;
++	ctx->Driver.DrawBuffer        = NULL;
++	ctx->Driver.Enable            = NULL;
++	ctx->Driver.FrontFace         = NULL;
++	ctx->Driver.Fogfv             = NULL;
++	ctx->Driver.Hint              = NULL;
++	ctx->Driver.Lightfv           = NULL;
++	ctx->Driver.LogicOpcode       = NULL;
++	ctx->Driver.PolygonMode       = NULL;
++	ctx->Driver.PolygonStipple    = NULL;
++	ctx->Driver.ReadBuffer        = NULL;
++	ctx->Driver.RenderMode        = NULL;
++	ctx->Driver.Scissor           = NULL;
++	ctx->Driver.ShadeModel        = glamoShadeModel;
++	ctx->Driver.LightModelfv      = NULL;
++	ctx->Driver.Viewport          = glamoViewport;
++	ctx->Driver.ResizeBuffers     = glamoResizeBuffers;
++	ctx->Driver.Flush             = glamoFlush;
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_state.h b/src/mesa/drivers/dri/glamo/glamo_state.h
+new file mode 100644
+index 0000000..98f0b97
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_state.h
+@@ -0,0 +1,34 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ * Roughly based on sis_state.h (c) 2003 Eric Anholt
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_STATE_H
++#define __GLAMO_STATE_H
++
++#include "main/context.h"
++
++extern void glamoInitStateFuncs(GLcontext *ctx);
++
++#endif   /* __GLAMO_STATE_H */
++
++/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.c b/src/mesa/drivers/dri/glamo/glamo_tris.c
+new file mode 100644
+index 0000000..6c6b5a6
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_tris.c
+@@ -0,0 +1,310 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS 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.
++ *
++ *
++ * Based on intel_tris.c, to which the following notice applies:
++ *
++ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ *
++ */
++
++
++#include <glamo_bo.h>
++#include <glamo_bo_gem.h>
++#include <glamo_drm.h>
++
++#include "main/mtypes.h"
++#include "swrast/swrast.h"
++#include "tnl/t_context.h"
++#include "tnl/t_vertex.h"
++#include "tnl/t_pipeline.h"
++
++#include "glamo_tris.h"
++#include "glamo_context.h"
++
++
++static void glamoRunPipeline(GLcontext *ctx)
++{
++	printf("glamoRunPipeline\n");
++
++	/* TODO: Emit state */
++
++	_tnl_run_pipeline(ctx);
++}
++
++
++static void glamoRenderStart(GLcontext *ctx)
++{
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++
++	/* Decide which attributes will be used */
++	gCtx->vertex_attrs[0].attrib = _TNL_ATTRIB_POS;
++	gCtx->vertex_attrs[0].format = EMIT_4F;
++
++	gCtx->vertex_size = _tnl_install_attrs(ctx, gCtx->vertex_attrs, 1,
++	                                       NULL, 0);
++}
++
++
++static void glamoRenderFinish(GLcontext *ctx)
++{
++	printf("glamoRenderFinish\n");
++}
++
++
++static void glamoPrimitiveNotify(GLcontext *ctx, GLenum prim)
++{
++	printf("glamoPrimitiveNotify\n");
++}
++
++
++uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, unsigned int count)
++{
++	uint32_t *addr;
++
++	printf("glamoGetPrimSpace\n");
++
++	/* Check for space in the existing VB */
++	if (gCtx->prim.vb_bo == NULL || (gCtx->prim.current_offset +
++	                           count * gCtx->vertex_size) > GLAMO_VB_SIZE) {
++
++		/* Not enough space, or no VB existing. Start a new one... */
++		if (gCtx->prim.vb == NULL) {
++			printf("Allocated %i bytes\n", GLAMO_VB_SIZE);
++			gCtx->prim.vb = malloc(GLAMO_VB_SIZE);
++		}
++		gCtx->prim.vb_bo = glamo_bo_open(gCtx->glamoScreen->bom, 0,
++		                                 GLAMO_VB_SIZE, 4,
++		                                 GLAMO_GEM_DOMAIN_VRAM, 0);
++		gCtx->prim.start_offset = 0;
++		gCtx->prim.current_offset = 0;
++	}
++
++	addr = (uint32_t *)(gCtx->prim.vb + gCtx->prim.current_offset);
++	gCtx->prim.current_offset += gCtx->vertex_size * count;
++	gCtx->prim.count += count;
++
++	return addr;
++}
++
++
++#define COPY_DWORDS( j, vb, vertsize, v )	\
++do {						\
++   for ( j = 0 ; j < vertsize ; j++ ) {		\
++      vb[j] = ((GLuint *)v)[j];			\
++   }						\
++   vb += vertsize;				\
++} while (0)
++
++
++static void glamo_draw_triangle(struct glamo_context *gCtx,
++                                glamoVertexPtr v0, glamoVertexPtr v1,
++                                glamoVertexPtr v2)
++{
++	GLuint *vb = glamoGetPrimSpace(gCtx, 3);
++	int j;
++
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v2);
++}
++
++
++static void glamo_draw_line(struct glamo_context *gCtx,
++                            glamoVertexPtr v0, glamoVertexPtr v1)
++{
++	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
++	int j;
++
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
++}
++
++
++static void glamo_draw_point(struct glamo_context *gCtx, glamoVertexPtr v0)
++{
++	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
++	int j;
++
++	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
++}
++
++
++#define TRI( a, b, c )                          \
++do {                                            \
++        glamo_draw_triangle(gCtx, a, b, c  );   \
++} while (0)
++
++
++#define QUAD( a, b, c, d )                      \
++printf("Drawing a quad\n");                     \
++do {                                            \
++        glamo_draw_triangle(gCtx, a, b, d);     \
++        glamo_draw_triangle(gCtx, b, c, d);     \
++} while (0)
++
++
++#define LINE(v0, v1)                            \
++do {                                            \
++        glamo_draw_line(gCtx, v0, v1);          \
++} while (0)
++
++
++#define POINT(v0)                               \
++do {                                            \
++        glamo_draw_point(gCtx, v0);             \
++} while (0)
++
++
++#define IND (0)
++#define TAG(x) x
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset_unfilled
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_offset_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++#define IND (0)
++#define TAG(x) x##_twoside_offset_unfilled_fallback
++#include "tnl_dd/t_dd_tritmp.h"
++
++
++static void init_rast_tab()
++{
++	init();
++	init_offset();
++	init_twoside();
++	init_twoside_offset();
++	init_unfilled();
++	init_offset_unfilled();
++	init_twoside_unfilled();
++	init_twoside_offset_unfilled();
++	init_fallback();
++	init_offset_fallback();
++	init_twoside_fallback();
++	init_twoside_offset_fallback();
++	init_unfilled_fallback();
++	init_offset_unfilled_fallback();
++	init_twoside_unfilled_fallback();
++	init_twoside_offset_unfilled_fallback();
++}
++
++
++void glamoInitTriFuncs(GLcontext *ctx)
++{
++	TNLcontext *tnl = TNL_CONTEXT(ctx);
++	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
++	static int firsttime = 1;
++
++	if (firsttime) {
++		init_rast_tab();
++		firsttime = 0;
++	}
++
++	gCtx->prim.start_offset = 0;
++	gCtx->prim.current_offset = 0;
++	gCtx->prim.vb_bo = NULL;
++	gCtx->prim.vb = NULL;
++	gCtx->prim.count = 0;
++
++	tnl->Driver.RunPipeline = glamoRunPipeline;
++	tnl->Driver.Render.Start = glamoRenderStart;
++	tnl->Driver.Render.Finish = glamoRenderFinish;
++	tnl->Driver.Render.PrimitiveNotify = glamoPrimitiveNotify;
++	tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
++	tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
++	tnl->Driver.Render.CopyPV = _tnl_copy_pv;
++	tnl->Driver.Render.Interp = _tnl_interp;
++}
+diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.h b/src/mesa/drivers/dri/glamo/glamo_tris.h
+new file mode 100644
+index 0000000..ba8f997
+--- /dev/null
++++ b/src/mesa/drivers/dri/glamo/glamo_tris.h
+@@ -0,0 +1,38 @@
++/*
++ * Direct Rendering Support for SMedia Glamo 336x/337x
++ *
++ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
++ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef __GLAMO_TRIS_H
++#define __GLAMO_TRIS_H
++
++#include "main/mtypes.h"
++
++#include "glamo_context.h"
++
++/* Amount of space reserved for vertex submission */
++#define GLAMO_VB_SIZE (32*1024)
++
++extern void glamoInitTriFuncs(GLcontext *ctx);
++extern uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx,
++                                   unsigned int count);
++
++#endif   /* __GLAMO_TRIS_H */
+diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
+index 39148f3..8244ec3 100644
+--- a/src/mesa/drivers/dri/glamo/glamo_screen.c
++++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
+@@ -166,7 +166,7 @@ static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
+    gfb = CALLOC_STRUCT(glamo_framebuffer);
+    if ( !gfb ) return GL_FALSE;
+ 
+-   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
++   _mesa_initialize_window_framebuffer(&gfb->base, mesaVis);
+ 
+    /* we only support this one format at the moment */
+    rgbFormat = GL_RGB5;
diff --git a/recipes/mesa/mesa-common.inc b/recipes/mesa/mesa-common.inc
index 3884112..51f7873 100644
--- a/recipes/mesa/mesa-common.inc
+++ b/recipes/mesa/mesa-common.inc
@@ -4,11 +4,17 @@ DESCRIPTION = "An open source implementation of the OpenGL spec"
 HOMEPAGE = "http://mesa3d.org"
 LICENSE = "MIT"
 
-INC_PR = "r7"
+INC_PR = "r8"
 PE = "2"
 
-SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2;name=archive \
-           ${SOURCEFORGE_MIRROR}/mesa3d/MesaDemos-${PV}.tar.bz2;name=demos "
+PROTO_DEPS = "xf86driproto glproto"
+LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
+
+DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
+
+SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
+           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
+          "
 S = "${WORKDIR}/Mesa-${PV}"
 
 PROVIDES = "virtual/libgl"
@@ -25,8 +31,10 @@ inherit glx-use-tls
 # Package contents vary according to ${MACHINE_DRI_MODULES}.
 PACKAGE_ARCH = "${MACHINE}"
 
-PACKAGES =+ "libegl libegl-dev libglu libglu-dev libosmesa libosmesa-dev libgl libgl-dev"
-FILES_libegl = "${libdir}/libEGL.so.*"
+PACKAGES =+ "libegl libegl-dev libegl-dbg libglu libglu-dev libosmesa libosmesa-dev libgl libgl-dev ${PN}-xprogs"
+FILES_${PN} += "${libdir}/dri/*.so"
+FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
+FILES_libegl = "${libdir}/libEGL.so.* ${libdir}/egl/*.so"
 FILES_libgl = "${libdir}/libGL.so.*"
 FILES_libglu = "${libdir}/libGLU.so.*"
 FILES_libosmesa = "${libdir}/libOSMesa.so.*"
@@ -36,6 +44,8 @@ FILES_libgl-dev = "${libdir}/libGL.* ${includedir}/GL"
 FILES_libglu-dev = "${libdir}/libGLU.* ${includedir}/GL/glu*.h"
 FILES_libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/osmesa.h"
 
+FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
+FILES_libegl-dbg += "${libdir}/egl/.debug/*"
 
 do_stage() {
         autotools_stage_all
diff --git a/recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch b/recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch
deleted file mode 100644
index f05d4b0..0000000
--- a/recipes/mesa/mesa-dri-7.8.2/fix-progs-makefile.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
-From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Thu, 4 Mar 2010 14:16:27 +0100
-Subject: [PATCH] fix libs
-
----
- progs/demos/Makefile   |    2 +-
- progs/glsl/Makefile    |    2 +-
- progs/redbook/Makefile |    2 +-
- progs/samples/Makefile |    2 +-
- progs/xdemos/Makefile  |    2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index 5b1d2a0..121b862 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
- 	$(APP_LIB_DEPS)
- 
- PROGS = \
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 3b5a595..836c4ac 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -10,7 +10,7 @@ LIB_DEP = \
- 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
- 	-l$(GL_LIB) $(APP_LIB_DEPS)
- 
- # using : to avoid APP_CC pointing to CC loop
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index b41e488..95ed746 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = aaindex \
- 	aapoly \
-diff --git a/progs/samples/Makefile b/progs/samples/Makefile
-index 64fa47a..9f72c8b 100644
---- a/progs/samples/Makefile
-+++ b/progs/samples/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
-diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
-index f866a32..c0f4e06 100644
---- a/progs/xdemos/Makefile
-+++ b/progs/xdemos/Makefile
-@@ -11,7 +11,7 @@
- # Add X11 and pthread libs to satisfy GNU gold.
- APP_LIB_DEPS += -lX11 -lpthread
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
-
- 
- PROGS = \
- 	corender \
--- 
-1.7.0
-
diff --git a/recipes/mesa/mesa-dri-7.8.2/glamo.patch b/recipes/mesa/mesa-dri-7.8.2/glamo.patch
deleted file mode 100644
index 52b4f3f..0000000
--- a/recipes/mesa/mesa-dri-7.8.2/glamo.patch
+++ /dev/null
@@ -1,2386 +0,0 @@
-diff --git a/configure.ac b/configure.ac
-index 61487c3..c4952bf 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -125,6 +125,9 @@ dnl Add flags for gcc and g++
- if test "x$GCC" = xyes; then
-     CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
- 
-+    # Work around GCC bug #39501
-+    CFLAGS="$CFLAGS -fno-finite-math-only"
-+
-     # Enable -fvisibility=hidden if using a gcc that supports it
-     save_CFLAGS="$CFLAGS"
-     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
-@@ -138,6 +141,9 @@ fi
- if test "x$GXX" = xyes; then
-     CXXFLAGS="$CXXFLAGS -Wall"
- 
-+    # Work around GCC bug #39501
-+    CXXFLAGS="$CXXFLAGS -fno-finite-math-only"
-+
-     # Work around aliasing bugs - developers should comment this out
-     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
- fi
-diff --git a/src/mesa/drivers/dri/glamo/Makefile b/src/mesa/drivers/dri/glamo/Makefile
-new file mode 100644
-index 0000000..e77193d
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/Makefile
-@@ -0,0 +1,22 @@
-+# src/mesa/drivers/dri/glamo/Makefile
-+
-+TOP = ../../../../..
-+include $(TOP)/configs/current
-+
-+LIBNAME = glamo_dri.so
-+
-+DRIVER_SOURCES = \
-+	glamo_screen.c glamo_context.c glamo_state.c glamo_fbo.c glamo_tris.c \
-+	glamo_cmdq.c glamo_render.c
-+
-+C_SOURCES = \
-+	$(COMMON_SOURCES) \
-+	$(DRIVER_SOURCES)
-+
-+ASM_SOURCES =
-+
-+DRI_LIB_DEPS += -ldrm_glamo
-+
-+include ../Makefile.template
-+
-+symlinks:
-diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.c b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
-new file mode 100644
-index 0000000..1334f8e
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.c
-@@ -0,0 +1,110 @@
-+/*
-+ * Command queue submission via DRM
-+ *
-+ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+
-+#include <stdint.h>
-+#include <stdlib.h>
-+#include <drm.h>
-+#include <glamo_drm.h>
-+#include <glamo_bo.h>
-+
-+#include "glamo_context.h"
-+#include "glamo_cmdq.h"
-+
-+
-+/* Submit the prepared command sequence to the kernel */
-+void glamoDRMDispatch(glamoContext *gCtx)
-+{
-+	drm_glamo_cmd_burst_t burst;
-+	int r;
-+
-+	burst.base = gCtx->cmd_burst_base;
-+	burst.data = gCtx->cmdq_drm;
-+	burst.bufsz = gCtx->cmdq_drm_used * 2;	/* -> bytes */
-+	burst.nobjs = gCtx->cmdq_obj_used;
-+	burst.objs = gCtx->cmdq_objs;
-+	burst.obj_pos = gCtx->cmdq_obj_pos;
-+
-+	r = drmCommandWrite(gCtx->drm_fd, DRM_GLAMO_CMDBURST,
-+	                    &burst, sizeof(burst));
-+	if ( r != 0 ) {
-+		fprintf(stderr, "DRM_GLAMO_CMDBURST failed\n");
-+	}
-+
-+	/* Reset counts to zero for the next sequence */
-+	gCtx->cmdq_obj_used = 0;
-+	gCtx->cmdq_drm_used = 0;
-+}
-+
-+
-+void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len)
-+{
-+	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
-+		fprintf(stderr, "Burst command too large\n");
-+		return;
-+	}
-+
-+	/* Record command */
-+	if ( len == 2 ) {
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff;
-+	} else if ( len == 4 ) {
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0x0000ffff;
-+		gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = val & 0xffff0000;
-+	} else {
-+		fprintf(stderr, "Wrong command length!\n");
-+	}
-+}
-+
-+
-+void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo)
-+{
-+	if ( gCtx->cmdq_drm_used+4 > gCtx->cmdq_drm_size ) {
-+		fprintf(stderr, "Burst command too large\n");
-+		return;
-+	}
-+
-+	/* Record object position */
-+	gCtx->cmdq_objs[gCtx->cmdq_obj_used] = bo->handle;
-+	/* -> bytes */
-+	gCtx->cmdq_obj_pos[gCtx->cmdq_obj_used] = gCtx->cmdq_drm_used * 2;
-+	gCtx->cmdq_obj_used++;
-+
-+	/* Record command */
-+	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
-+	gCtx->cmdq_drm[gCtx->cmdq_drm_used++] = 0x0000;
-+}
-+
-+
-+void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base)
-+{
-+	gCtx->cmd_burst_base = base;
-+}
-+
-+
-+void glamoInitCmdqCache(glamoContext *gCtx)
-+{
-+	gCtx->cmdq_objs = malloc(1024);
-+	gCtx->cmdq_obj_pos = malloc(1024);
-+	gCtx->cmdq_obj_used = 0;
-+	gCtx->cmdq_drm_used = 0;
-+	gCtx->cmdq_drm_size = 4 * 1024;
-+	gCtx->cmdq_drm = malloc(gCtx->cmdq_drm_size);
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_cmdq.h b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
-new file mode 100644
-index 0000000..7420d7b
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_cmdq.h
-@@ -0,0 +1,33 @@
-+/*
-+ * Command queue submission via DRM
-+ *
-+ * Copyright 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+
-+#include <stdint.h>
-+#include <glamo_bo.h>
-+
-+#include "glamo_context.h"
-+
-+
-+extern void glamoDRMDispatch(glamoContext *gCtx);
-+extern void glamoDRMAddBO(glamoContext *gCtx, struct glamo_bo *bo);
-+extern void glamoDRMAddData(glamoContext *gCtx, uint32_t val, int len);
-+extern void glamoDRMStartBurst(glamoContext *gCtx, uint16_t base);
-+extern void glamoInitCmdqCache(glamoContext *gCtx);
-diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
-new file mode 100644
-index 0000000..527654f
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_context.c
-@@ -0,0 +1,360 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_context.c (c) 2003 Eric Anholt
-+ *              and radeon_common_context.c
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "dri_util.h"
-+#include "drirenderbuffer.h"
-+#include "utils.h"
-+
-+#include "swrast/swrast.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "drivers/common/driverfuncs.h"
-+#include "vbo/vbo.h"
-+#include "tnl/tnl.h"
-+#include "tnl/t_pipeline.h"
-+#include "main/state.h"
-+
-+#include "glamo_context.h"
-+#include "glamo_screen.h"
-+#include "glamo_state.h"
-+#include "glamo_fbo.h"
-+#include "glamo_tris.h"
-+#include "glamo_render.h"
-+#include "glamo_cmdq.h"
-+
-+#include <glamo_bo.h>
-+#include <glamo_bo_gem.h>
-+#include <glamo_drm.h>
-+
-+
-+#define DRIVER_DATE  "20090913"
-+
-+
-+static inline struct glamo_renderbuffer *glamo_get_renderbuffer(
-+                                                      struct gl_framebuffer *fb,
-+                                                      int att_index)
-+{
-+	if ( att_index >= 0 ) {
-+		struct glamo_renderbuffer *gr;
-+		gr = glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer);
-+		return gr;
-+	} else {
-+		return NULL;
-+	}
-+}
-+
-+
-+static const GLubyte *glamoGetString(GLcontext *ctx, GLenum name)
-+{
-+	static char buffer[128];
-+
-+	switch (name) {
-+	case GL_VENDOR:
-+		return (GLubyte *)"Thomas White";
-+	case GL_RENDERER: {
-+		driGetRendererString(buffer, "Glamo", DRIVER_DATE, 0);
-+		return (GLubyte *) buffer;
-+	}
-+	default:
-+		return 0;
-+	}
-+}
-+
-+
-+/* Called when Mesa needs to know the size of the framebuffer */
-+static void glamoBufferSize(GLframebuffer *buffer,
-+                            GLuint *width, GLuint *height)
-+{
-+	GET_CURRENT_CONTEXT(ctx);
-+	glamoContextPtr glamo = GLAMO_CONTEXT(ctx);
-+
-+	*width = glamo->driDrawable->w;
-+	*height = glamo->driDrawable->h;
-+}
-+
-+
-+GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
-+                             __DRIcontext *driContextPriv,
-+                             void *sharedContextPrivate)
-+{
-+	GLcontext *ctx, *shareCtx;
-+	__DRIscreen *sPriv = driContextPriv->driScreenPriv;
-+	glamoContextPtr context;
-+	glamoScreenPtr glamoScreen;
-+	struct dd_function_table functions;
-+
-+	context = (glamoContextPtr)CALLOC(sizeof(*context));
-+	if ( context == NULL ) return GL_FALSE;
-+
-+	_mesa_init_driver_functions(&functions);
-+
-+	/* Allocate the Mesa context */
-+	if ( sharedContextPrivate )
-+		shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
-+	else
-+		shareCtx = NULL;
-+	context->glCtx = _mesa_create_context(glVisual, shareCtx,
-+		                        &functions, (void *)context);
-+	if ( context->glCtx == NULL ) {
-+		FREE(context);
-+		return GL_FALSE;
-+	}
-+	driContextPriv->driverPrivate = context;
-+	ctx = context->glCtx;
-+
-+	glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
-+
-+	ctx->Driver.GetString = glamoGetString;
-+	ctx->Driver.GetBufferSize = glamoBufferSize;
-+
-+	context->driContext = driContextPriv;
-+	context->driScreen = sPriv;
-+	context->driDrawable = NULL;
-+	context->drm_fd = sPriv->fd;
-+
-+	/* Initialize the software rasterizer and helper modules. */
-+	_swrast_CreateContext(ctx);
-+	_vbo_CreateContext(ctx);
-+	_tnl_CreateContext(ctx);
-+	_swsetup_CreateContext(ctx);
-+
-+	/* Install our pipeline (see glamo_render.c) */
-+	_tnl_install_pipeline(ctx, glamo_pipeline);
-+
-+	_swrast_allow_pixel_fog(ctx, GL_TRUE);
-+	_swrast_allow_vertex_fog(ctx, GL_FALSE);
-+	_tnl_allow_pixel_fog(ctx, GL_TRUE);
-+	_tnl_allow_vertex_fog(ctx, GL_FALSE);
-+
-+	glamoInitCmdqCache(context);
-+	glamoInitStateFuncs(ctx);
-+	glamoInitTriFuncs(ctx);
-+
-+	return GL_TRUE;
-+}
-+
-+
-+void glamoDestroyContext(__DRIcontext *driContextPriv)
-+{
-+	glamoContextPtr context;
-+
-+	context = (glamoContextPtr)driContextPriv->driverPrivate;
-+	assert(context != NULL);
-+
-+	if ( context != NULL ) {
-+
-+		_swsetup_DestroyContext(context->glCtx);
-+		_tnl_DestroyContext(context->glCtx);
-+		_vbo_DestroyContext(context->glCtx);
-+		_swrast_DestroyContext(context->glCtx);
-+
-+		_mesa_destroy_context(context->glCtx);
-+
-+	}
-+
-+	FREE(context);
-+}
-+
-+
-+void glamo_update_renderbuffers(__DRIcontext *context,
-+                                __DRIdrawable *drawable)
-+{
-+	unsigned int attachments[10];
-+	__DRIbuffer *buffers;
-+	__DRIscreen *screen;
-+	int i, count;
-+	struct glamo_framebuffer *draw;
-+	glamoContextPtr glamo;
-+	struct glamo_bo *bo;
-+
-+	draw = drawable->driverPrivate;
-+	screen = context->driScreenPriv;
-+	glamo = (glamoContextPtr)context->driverPrivate;
-+	i = 0;
-+	if ( draw->color_rb[0] ) {
-+		attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-+	}
-+	if ( draw->color_rb[1] ) {
-+		attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-+	}
-+
-+	buffers = screen->dri2.loader->getBuffers(drawable,
-+	                                          &drawable->w,
-+	                                          &drawable->h,
-+	                                          attachments, i,
-+	                                          &count,
-+	                                          drawable->loaderPrivate);
-+	if ( buffers == NULL ) return;
-+
-+	/* Set one cliprect to cover the whole drawable */
-+	drawable->x = 0;
-+	drawable->y = 0;
-+	drawable->backX = 0;
-+	drawable->backY = 0;
-+	drawable->numClipRects = 1;
-+	drawable->pClipRects[0].x1 = 0;
-+	drawable->pClipRects[0].y1 = 0;
-+	drawable->pClipRects[0].x2 = drawable->w;
-+	drawable->pClipRects[0].y2 = drawable->h;
-+	drawable->numBackClipRects = 1;
-+	drawable->pBackClipRects[0].x1 = 0;
-+	drawable->pBackClipRects[0].y1 = 0;
-+	drawable->pBackClipRects[0].x2 = drawable->w;
-+	drawable->pBackClipRects[0].y2 = drawable->h;
-+
-+	/* For each attachment */
-+	for ( i=0; i<count; i++ ) {
-+
-+		struct glamo_renderbuffer *grb;
-+
-+		switch ( buffers[i].attachment ) {
-+		case __DRI_BUFFER_FRONT_LEFT:
-+			grb = draw->color_rb[0];
-+			break;
-+		case __DRI_BUFFER_BACK_LEFT:
-+			grb = draw->color_rb[1];
-+			break;
-+		case __DRI_BUFFER_DEPTH:
-+			grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH);
-+			break;
-+		case __DRI_BUFFER_STENCIL:
-+			grb = glamo_get_renderbuffer(&draw->base,
-+			                                        BUFFER_STENCIL);
-+			break;
-+		case __DRI_BUFFER_FAKE_FRONT_LEFT:
-+			grb = draw->color_rb[0];
-+			break;
-+		case __DRI_BUFFER_ACCUM:
-+		default:
-+			fprintf(stderr,
-+				"Unhandled buffer attach event,"
-+				" attachment type %d\n", buffers[i].attachment);
-+			return;
-+		}
-+
-+		if ( grb == NULL ) {
-+			/* Don't know how to handle this type of buffer */
-+			continue;
-+		}
-+
-+		if ( grb->bo ) {
-+			uint32_t name = glamo_gem_get_name(grb->bo);
-+			if ( name == buffers[i].name ) {
-+				/* Buffer already attached.  No action needed */
-+				continue;
-+			}
-+		}
-+
-+		grb->cpp = buffers[i].cpp;
-+		grb->pitch = buffers[i].pitch;
-+		grb->width = drawable->w;
-+		grb->height = drawable->h;
-+
-+		bo = glamo_bo_open(glamo->glamoScreen->bom, buffers[i].name,
-+		                   0, 0, GLAMO_GEM_DOMAIN_VRAM,
-+		                   buffers[i].flags);
-+		if ( bo == NULL ) {
-+			fprintf(stderr, "Failed to attach buffer %d\n",
-+				buffers[i].name);
-+		}
-+
-+		glamo_renderbuffer_set_bo(grb, bo);
-+		glamo_bo_unref(bo);
-+
-+	}
-+
-+	driUpdateFramebufferSize(glamo->glCtx, drawable);
-+}
-+
-+
-+GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
-+                           __DRIdrawable *driDrawPriv,
-+                           __DRIdrawable *driReadPriv)
-+{
-+	struct glamo_framebuffer *draw_fb;
-+	struct gl_framebuffer *read_fb;
-+	glamoContextPtr glamo;
-+
-+	if ( driContextPriv == NULL ) {
-+		_mesa_make_current(NULL, NULL, NULL);
-+		return GL_TRUE;
-+	}
-+
-+	/* The Glamo context we're switching to */
-+	glamo = (glamoContextPtr)driContextPriv->driverPrivate;
-+
-+	glamo->driDrawable = driDrawPriv;
-+
-+	/* These two will probably be the same */
-+	draw_fb = (struct glamo_framebuffer *)driDrawPriv->driverPrivate;
-+	read_fb = (struct gl_framebuffer *)driReadPriv->driverPrivate;
-+
-+	glamo_update_renderbuffers(driContextPriv, driDrawPriv);
-+	if (driDrawPriv != driReadPriv)
-+		glamo_update_renderbuffers(driContextPriv, driReadPriv);
-+
-+	_mesa_make_current(glamo->glCtx, &draw_fb->base, read_fb);
-+	_mesa_update_state(glamo->glCtx);
-+
-+	return GL_TRUE;
-+}
-+
-+
-+GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
-+{
-+	return GL_TRUE;
-+}
-+
-+
-+/* Convert IEEE754 32-bit float to Glamo's signed 24-bit float */
-+uint32_t float7s16(GLfloat in)
-+{
-+	uint32_t a, b;
-+	uint32_t sign, expo, mant;  /* Sign, exponent, significand */
-+
-+	a = *(uint32_t *)&in;
-+
-+	/* This is bad */
-+	if ( a & 0x40000000 ) {
-+		printf(stderr, "Warning: Exponent won't fit into 7 bits\n");
-+	}
-+
-+	/* This hopefully isn't a big problem */
-+	if ( a & 0x0000007f ) {
-+		printf(stderr, "Warning: Precision lost in FP conversion\n");
-+	}
-+
-+	/* Separate out the right bits */
-+	mant = a & 0x007fff80;  /* Bits 7-22 (bits 0-6 are lost) */
-+	expo = a & 0x3f800000;  /* Bits 23-29 (bit 30 is lost) */
-+	sign = a & 0x80000000;  /* Bit 31 */
-+
-+	/* Shift and recombine */
-+	b  = sign >> 8;  /* Fills bit 23 */
-+	b |= expo >> 7;  /* Fills bits 16-22 */
-+	b |= mant >> 7;  /* Fills bits 0-15 */
-+
-+	return b;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_context.h b/src/mesa/drivers/dri/glamo/glamo_context.h
-new file mode 100644
-index 0000000..ccce29c
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_context.h
-@@ -0,0 +1,106 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_context.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_CONTEXT_H
-+#define __GLAMO_CONTEXT_H
-+
-+
-+#include "dri_util.h"
-+#include "utils.h"
-+#include "tnl/t_vertex.h"
-+
-+#include "glamo_screen.h"
-+
-+
-+typedef struct glamo_context glamoContext;
-+typedef struct glamo_context *glamoContextPtr;
-+
-+struct glamo_context {
-+
-+	GLcontext *glCtx;                  /* Must be first in this structure */
-+
-+	int drm_fd;                        /* DRM fd */
-+
-+	__DRIcontext  *driContext;  /* DRI context */
-+	__DRIscreen   *driScreen;   /* DRI screen */
-+	__DRIdrawable *driDrawable; /* DRI drawable bound to this ctx */
-+
-+	glamoScreenPtr glamoScreen;        /* Screen private DRI data */
-+
-+	driOptionCache optionCache;
-+
-+	uint16_t *cmdq_drm;                /* Command queue cache */
-+	uint16_t cmd_burst_base;
-+	int cmdq_drm_used;
-+	int cmdq_drm_size;
-+	int cmdq_obj_used;
-+	uint32_t *cmdq_objs;
-+	unsigned int *cmdq_obj_pos;
-+
-+	/* Information about the current primitive */
-+	struct {
-+		GLuint id;
-+		uint32_t primitive;	/* Current hardware primitive type */
-+		struct glamo_bo *vb_bo;
-+		uint8_t *vb;
-+		unsigned int start_offset; /* Byte offset of start */
-+		unsigned int current_offset; /* Byte offset of next vertex */
-+		unsigned int count;	/* Number of vertices */
-+	} prim;
-+
-+	/* Current vertex format and attributes */
-+	int vertex_size;
-+	struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
-+
-+	/* State */
-+	GLuint new_state;      /* State which must be updated */
-+	uint16_t col_clear;
-+
-+};
-+
-+#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))
-+
-+#define TAG(x) glamo##x
-+#include "tnl_dd/t_dd_vertex.h"
-+#undef TAG
-+
-+extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
-+                                    __DRIcontext *driContextPriv,
-+                                    void *sharedContextPrivate);
-+extern void glamoDestroyContext(__DRIcontext *dcp);
-+extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
-+                                  __DRIdrawable *driDrawPriv,
-+                                  __DRIdrawable *driReadPriv);
-+extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
-+extern void glamo_update_renderbuffers(__DRIcontext *context,
-+                                       __DRIdrawable *drawable);
-+
-+#define GLAMO_PACKCOLOR565(r, g, b) \
-+	((((r) & 0xf8) << 8)        \
-+	| (((g) & 0xfc) << 3)       \
-+	| (((b) & 0xf8) >> 3))
-+
-+extern uint32_t float7s16(GLfloat in);
-+
-+#endif   /* __GLAMO_CONTEXT_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c
-new file mode 100644
-index 0000000..c866d21
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c
-@@ -0,0 +1,130 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on radeon_fbo.c (c) 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"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "main/imports.h"
-+#include "main/macros.h"
-+#include "main/mtypes.h"
-+#include "main/formats.h"
-+#include "main/fbobject.h"
-+#include "main/framebuffer.h"
-+#include "main/renderbuffer.h"
-+#include "main/context.h"
-+#include "dri_util.h"
-+
-+/* This comes from libdrm_glamo */
-+#include <glamo_bo.h>
-+
-+#include "glamo_fbo.h"
-+
-+
-+static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb)
-+{
-+   struct glamo_renderbuffer *grb = glamo_renderbuffer(rb);
-+
-+   ASSERT(grb);
-+
-+   if ( grb && grb->bo ) {
-+      glamo_bo_unref(grb->bo);
-+   }
-+   _mesa_free(grb);
-+}
-+
-+
-+static void *glamo_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb,
-+                               GLint x, GLint y)
-+{
-+   return NULL;   /* Can't be directly addressed */
-+}
-+
-+
-+/* Called for each hardware renderbuffer when a _window_ is resized.
-+ * Just update fields.
-+ * Not used for user-created renderbuffers!
-+ */
-+static GLboolean glamo_alloc_window_storage(GLcontext *ctx,
-+                                            struct gl_renderbuffer *rb,
-+                                            GLenum internalFormat,
-+                                            GLuint width, GLuint height)
-+{
-+   ASSERT(rb->Name == 0);
-+   rb->Width = width;
-+   rb->Height = height;
-+   rb->Format = internalFormat;
-+   return GL_TRUE;
-+}
-+
-+
-+/* Create a buffer, such as a colour or depth buffer */
-+struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
-+                                              __DRIdrawable *driDrawPriv)
-+{
-+   struct glamo_renderbuffer *grb;
-+
-+   grb = CALLOC_STRUCT(glamo_renderbuffer);
-+   if ( !grb ) return NULL;
-+
-+   _mesa_init_renderbuffer(&grb->base, 0);
-+   grb->base.ClassID = GLAMO_RB_CLASS;
-+
-+   switch (format) {
-+      case GL_RGB5:
-+         grb->base.Format = MESA_FORMAT_RGB565;
-+         grb->base._BaseFormat = GL_RGB;
-+
-+         grb->base.DataType = GL_UNSIGNED_BYTE;
-+         break;
-+      case GL_DEPTH_COMPONENT16:
-+         grb->base.DataType = GL_UNSIGNED_SHORT;
-+	 grb->base._BaseFormat = GL_DEPTH_COMPONENT;
-+         break;
-+      default:
-+         fprintf(stderr, "%s: Unknown format 0x%04x\n", __FUNCTION__, format);
-+         _mesa_delete_renderbuffer(&grb->base);
-+         return NULL;
-+   }
-+
-+   grb->dPriv = driDrawPriv;
-+   grb->base.InternalFormat = format;
-+
-+   grb->base.Delete = glamo_delete_renderbuffer;
-+   grb->base.AllocStorage = glamo_alloc_window_storage;
-+   grb->base.GetPointer = glamo_get_pointer;
-+
-+   return grb;
-+}
-+
-+
-+void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
-+                               struct glamo_bo *bo)
-+{
-+  struct glamo_bo *old;
-+  old = grb->bo;
-+  grb->bo = bo;
-+  glamo_bo_ref(bo);
-+  if ( old ) glamo_bo_unref(old);
-+}
-+
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h
-new file mode 100644
-index 0000000..48210dd
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h
-@@ -0,0 +1,77 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_FBO_H
-+#define __GLAMO_FBO_H
-+
-+
-+#include "main/mtypes.h"
-+#include "dri_util.h"
-+
-+
-+/* This is just a marker so we can tell a Glamo renderbuffer from a Mesa one */
-+#define GLAMO_RB_CLASS (0xdeadbeef)
-+
-+
-+struct glamo_renderbuffer
-+{
-+	struct gl_renderbuffer base;   /* Must be first */
-+	struct glamo_bo *bo;
-+	unsigned int cpp;
-+	unsigned int pitch;
-+	unsigned int width;
-+	unsigned int height;
-+
-+	__DRIdrawable *dPriv;
-+};
-+
-+
-+struct glamo_framebuffer
-+{
-+	struct gl_framebuffer base;
-+	struct glamo_renderbuffer *color_rb[2];
-+};
-+
-+
-+/* This is just a small wrapper function to return NULL if the gl_renderbuffer
-+ * is not a glamo_renderbuffer */
-+static inline struct glamo_renderbuffer
-+                                 *glamo_renderbuffer(struct gl_renderbuffer *rb)
-+{
-+	struct glamo_renderbuffer *grb = (struct glamo_renderbuffer *)rb;
-+	if ( grb && grb->base.ClassID == GLAMO_RB_CLASS )
-+		return grb;
-+	else
-+		return NULL;
-+}
-+
-+
-+extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format,
-+                                             __DRIdrawable *driDrawPriv);
-+
-+extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb,
-+                               struct glamo_bo *bo);
-+
-+#endif   /* __GLAMO_FBO_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_regs.h b/src/mesa/drivers/dri/glamo/glamo_regs.h
-new file mode 100644
-index 0000000..02b2294
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_regs.h
-@@ -0,0 +1,174 @@
-+#ifndef _GLAMO_REGS_H
-+#define _GLAMO_REGS_H
-+
-+/* Smedia Glamo 336x/337x driver
-+ *
-+ * (C) 2007 by OpenMoko, Inc.
-+ * Author: Harald Welte <laforge@openmoko.org>
-+ * All rights reserved.
-+ *
-+ * Modified for Glamo Mesa driver by Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License as
-+ * published by the Free Software Foundation; either version 2 of
-+ * the License, or (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ * MA 02111-1307 USA
-+ */
-+
-+enum glamo_regster_offsets {
-+	GLAMO_REGOFS_GENERIC	= 0x0000,
-+	GLAMO_REGOFS_HOSTBUS	= 0x0200,
-+	GLAMO_REGOFS_MEMORY	= 0x0300,
-+	GLAMO_REGOFS_VIDCAP	= 0x0400,
-+	GLAMO_REGOFS_ISP	= 0x0500,
-+	GLAMO_REGOFS_JPEG	= 0x0800,
-+	GLAMO_REGOFS_MPEG	= 0x0c00,
-+	GLAMO_REGOFS_LCD	= 0x1100,
-+	GLAMO_REGOFS_MMC	= 0x1400,
-+	GLAMO_REGOFS_MPROC0	= 0x1500,
-+	GLAMO_REGOFS_MPROC1	= 0x1580,
-+	GLAMO_REGOFS_CMDQUEUE	= 0x1600,
-+	GLAMO_REGOFS_RISC	= 0x1680,
-+	GLAMO_REGOFS_2D		= 0x1700,
-+	GLAMO_REGOFS_3D		= 0x1b00,
-+};
-+
-+
-+#define REG_MPEG(x)           (GLAMO_REGOFS_MPEG+(x))
-+
-+enum glamo_register_mpeg {
-+      //
-+      GLAMO_REG_MPEG_DC_ADDRL         = REG_MPEG(0x3c),
-+      GLAMO_REG_MPEG_DC_ADDRH         = REG_MPEG(0x3e),
-+      GLAMO_REG_MPEG_AC_ADDRL         = REG_MPEG(0x40),
-+      GLAMO_REG_MPEG_AC_ADDRH         = REG_MPEG(0x42),
-+      //
-+      GLAMO_REG_MPEG_SAFE_1           = REG_MPEG(0x60),
-+      GLAMO_REG_MPEG_SAFE_2           = REG_MPEG(0x62),
-+      GLAMO_REG_MPEG_SAFE_3           = REG_MPEG(0x64),
-+      //
-+      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRL = REG_MPEG(0x6e),
-+      GLAMO_REG_MPEG_DEC_OUT0_Y_ADDRH = REG_MPEG(0x70),
-+      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRL = REG_MPEG(0x72),
-+      GLAMO_REG_MPEG_DEC_OUT0_U_ADDRH = REG_MPEG(0x74),
-+      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRL = REG_MPEG(0x76),
-+      GLAMO_REG_MPEG_DEC_OUT0_V_ADDRH = REG_MPEG(0x78),
-+      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRL = REG_MPEG(0x7a),
-+      GLAMO_REG_MPEG_DEC_OUT1_Y_ADDRH = REG_MPEG(0x7c),
-+      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRL = REG_MPEG(0x7e),
-+      GLAMO_REG_MPEG_DEC_OUT1_U_ADDRH = REG_MPEG(0x80),
-+      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRL = REG_MPEG(0x82),
-+      GLAMO_REG_MPEG_DEC_OUT1_V_ADDRH = REG_MPEG(0x84),
-+      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRL = REG_MPEG(0x86),
-+      GLAMO_REG_MPEG_DEC_OUT2_Y_ADDRH = REG_MPEG(0x88),
-+      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRL = REG_MPEG(0x8a),
-+      GLAMO_REG_MPEG_DEC_OUT2_U_ADDRH = REG_MPEG(0x8c),
-+      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRL = REG_MPEG(0x8e),
-+      GLAMO_REG_MPEG_DEC_OUT2_V_ADDRH = REG_MPEG(0x90),
-+      GLAMO_REG_MPEG_DEC_WIDTH        = REG_MPEG(0x92),
-+      GLAMO_REG_MPEG_DEC_HEIGHT       = REG_MPEG(0x94),
-+      GLAMO_REG_MPEG_SPECIAL          = REG_MPEG(0x96),
-+      GLAMO_REG_MPEG_DEC_IN_ADDRL     = REG_MPEG(0x98),
-+      GLAMO_REG_MPEG_DEC_IN_ADDRH     = REG_MPEG(0x9a),
-+      //
-+      GLAMO_REG_MPEG_DEBLK_THRESHOLD  = REG_MPEG(0xc0),
-+      //
-+      GLAMO_REG_MPEG_DEC_STATUS       = REG_MPEG(0xc8),
-+      GLAMO_REG_MPEG_DEC_RB0          = REG_MPEG(0xca),
-+      GLAMO_REG_MPEG_DEC_RB1          = REG_MPEG(0xcc),
-+};
-+
-+
-+#define REG_2D(x)		(GLAMO_REGOFS_2D+(x))
-+
-+enum glamo_register_2d {
-+	GLAMO_REG_2D_SRC_ADDRL		= REG_2D(0x00),
-+	GLAMO_REG_2D_SRC_ADDRH		= REG_2D(0x02),
-+	GLAMO_REG_2D_SRC_PITCH		= REG_2D(0x04),
-+	GLAMO_REG_2D_SRC_X		= REG_2D(0x06),
-+	GLAMO_REG_2D_SRC_Y		= REG_2D(0x08),
-+	GLAMO_REG_2D_DST_X		= REG_2D(0x0a),
-+	GLAMO_REG_2D_DST_Y		= REG_2D(0x0c),
-+	GLAMO_REG_2D_DST_ADDRL		= REG_2D(0x0e),
-+	GLAMO_REG_2D_DST_ADDRH		= REG_2D(0x10),
-+	GLAMO_REG_2D_DST_PITCH		= REG_2D(0x12),
-+	GLAMO_REG_2D_DST_HEIGHT		= REG_2D(0x14),
-+	GLAMO_REG_2D_RECT_WIDTH		= REG_2D(0x16),
-+	GLAMO_REG_2D_RECT_HEIGHT	= REG_2D(0x18),
-+	GLAMO_REG_2D_PAT_ADDRL		= REG_2D(0x1a),
-+	GLAMO_REG_2D_PAT_ADDRH		= REG_2D(0x1c),
-+	GLAMO_REG_2D_PAT_FG		= REG_2D(0x1e),
-+	GLAMO_REG_2D_PAT_BG		= REG_2D(0x20),
-+	GLAMO_REG_2D_SRC_FG		= REG_2D(0x22),
-+	GLAMO_REG_2D_SRC_BG		= REG_2D(0x24),
-+	GLAMO_REG_2D_MASK1		= REG_2D(0x26),
-+	GLAMO_REG_2D_MASK2		= REG_2D(0x28),
-+	GLAMO_REG_2D_MASK3		= REG_2D(0x2a),
-+	GLAMO_REG_2D_MASK4		= REG_2D(0x2c),
-+	GLAMO_REG_2D_ROT_X		= REG_2D(0x2e),
-+	GLAMO_REG_2D_ROT_Y		= REG_2D(0x30),
-+	GLAMO_REG_2D_LEFT_CLIP		= REG_2D(0x32),
-+	GLAMO_REG_2D_TOP_CLIP		= REG_2D(0x34),
-+	GLAMO_REG_2D_RIGHT_CLIP		= REG_2D(0x36),
-+	GLAMO_REG_2D_BOTTOM_CLIP	= REG_2D(0x38),
-+	GLAMO_REG_2D_COMMAND1		= REG_2D(0x3A),
-+	GLAMO_REG_2D_COMMAND2		= REG_2D(0x3C),
-+	GLAMO_REG_2D_COMMAND3		= REG_2D(0x3E),
-+	GLAMO_REG_2D_SAFE		= REG_2D(0x40),
-+	GLAMO_REG_2D_STATUS		= REG_2D(0x42),
-+	GLAMO_REG_2D_ID1		= REG_2D(0x44),
-+	GLAMO_REG_2D_ID2		= REG_2D(0x46),
-+	GLAMO_REG_2D_ID3		= REG_2D(0x48),
-+};
-+
-+
-+/* No offset this time */
-+#define REG_3D(x)		(x)
-+
-+enum glamo_register_3d
-+{
-+	/* Fire the engine */
-+	G3D_FIRE			= REG_3D(0x2058),
-+
-+	/* Streams of vertex/colour/normal/texcoord data */
-+	G3D_ACTIVE_STREAMS		= REG_3D(0x1f00),
-+	G3D_LAST_STREAM__VCOLFMT	= REG_3D(0x2030),
-+	G3D_STREAM_MODE_0		= REG_3D(0x1f10),
-+	G3D_STREAM_BASE_0		= REG_3D(0x1f14),
-+	G3D_STREAM_MODE_1		= REG_3D(0x1f18),
-+	G3D_STREAM_BASE_1		= REG_3D(0x1f1c),
-+	G3D_STREAM_MODE_2		= REG_3D(0x1f20),
-+	G3D_STREAM_BASE_2		= REG_3D(0x1f24),
-+	G3D_STREAM_MODE_3		= REG_3D(0x1f28),
-+	G3D_STREAM_BASE_3		= REG_3D(0x1f2c),
-+	G3D_STREAM_MODE_4		= REG_3D(0x1f30),
-+	G3D_STREAM_BASE_4		= REG_3D(0x1f34),
-+	G3D_STREAM_MODE_5		= REG_3D(0x1f38),
-+	G3D_STREAM_BASE_5		= REG_3D(0x1f3c),
-+	G3D_STREAM_MODE_6		= REG_3D(0x1f40),
-+	G3D_STREAM_BASE_6		= REG_3D(0x1f44),
-+	G3D_STREAM_MODE_7		= REG_3D(0x1f48),
-+	G3D_STREAM_BASE_7		= REG_3D(0x1f4c),
-+
-+	/* Modelview*projection matrix */
-+	G3D_MATRIX_MVP			= REG_3D(0x26a0), /* .. 0x27df */
-+
-+	/* Modelview matrix */
-+	G3D_MATRIX_MV			= REG_3D(0x26e0), /* .. 0x270f */
-+
-+	/* Inverse MVP, 3x3 only */
-+	G3D_MATRIX_IMVP			= REG_3D(0x2710), /* .. 0x2733 */
-+
-+};
-+
-+#endif /* _GLAMO_REGS_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_render.c b/src/mesa/drivers/dri/glamo/glamo_render.c
-new file mode 100644
-index 0000000..fd52418
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_render.c
-@@ -0,0 +1,230 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Based on intel_render.c, to which the following notice applies:
-+ *
-+ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS 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.
-+ *
-+ */
-+
-+
-+/*
-+ * Render unclipped vertex buffers by emitting vertices directly to
-+ * dma buffers.  Use strip/fan hardware acceleration where possible.
-+ *
-+ */
-+#include "main/glheader.h"
-+#include "main/context.h"
-+#include "main/macros.h"
-+#include "main/imports.h"
-+#include "main/mtypes.h"
-+#include "main/enums.h"
-+
-+#include "tnl/t_context.h"
-+#include "tnl/t_vertex.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "glamo_context.h"
-+#include "glamo_tris.h"
-+#include "glamo_regs.h"
-+
-+/*
-+ * Render unclipped vertex buffers by emitting vertices directly to
-+ * VRAM buffers.  Use strip/fan hardware primitives where possible.
-+ * Try to simulate missing primitives with indexed vertices.
-+ */
-+#define HAVE_POINTS      1
-+#define HAVE_LINES       1
-+#define HAVE_LINE_STRIPS 0
-+#define HAVE_TRIANGLES   1
-+#define HAVE_TRI_STRIPS  0
-+#define HAVE_TRI_STRIP_1 0
-+#define HAVE_TRI_FANS    0
-+#define HAVE_POLYGONS    0
-+#define HAVE_QUADS       0
-+#define HAVE_QUAD_STRIPS 0
-+#define HAVE_ELTS        0
-+
-+
-+static void glamoFlushPrim(struct glamo_context *gCtx)
-+{
-+	printf("glamoFlushPrim: %i vertices, %i %i\n", gCtx->prim.count,
-+	gCtx->prim.start_offset, gCtx->prim.current_offset);
-+
-+	if ( gCtx->prim.vb_bo == NULL ) return;
-+
-+	/* Upload to hardware */
-+	glamo_bo_subdata(gCtx->prim.vb_bo, 0, gCtx->prim.current_offset,
-+	                 gCtx->prim.vb);
-+
-+	/* Dispatch to the hardware */
-+	glamoDRMStartBurst(gCtx, G3D_STREAM_MODE_0);
-+	glamoDRMAddData(gCtx, 0x000f0300, 4);
-+	glamoDRMAddBO(gCtx, gCtx->prim.vb_bo);
-+	glamoDRMDispatch(gCtx);
-+
-+	/* Please use a new BO for the next buffer */
-+	gCtx->prim.vb_bo = NULL;
-+
-+	/* Continue from new start */
-+	gCtx->prim.start_offset = gCtx->prim.current_offset;
-+}
-+
-+
-+static inline GLuint glamoGetVBMax(struct glamo_context *gCtx)
-+{
-+	return GLAMO_VB_SIZE / gCtx->vertex_size;
-+}
-+
-+
-+static inline GLuint glamoGetCurrentMax(struct glamo_context *gCtx)
-+{
-+	/* How many more vertices can be accommodated?
-+	 * Each vertex takes up 4x 32-bit fixed point values */
-+	return (GLAMO_VB_SIZE - gCtx->prim.current_offset) / gCtx->vertex_size;
-+}
-+
-+
-+#define LOCAL_VARS \
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+#define INIT(prim)
-+
-+#define FLUSH() glamoFlushPrim(gCtx)
-+
-+#define GET_SUBSEQUENT_VB_MAX_VERTS() glamoGetVBMax(gCtx)
-+#define GET_CURRENT_VB_MAX_VERTS() glamoGetCurrentMax(gCtx)
-+
-+#define ALLOC_VERTS(nr) glamoGetPrimSpace(gCtx, nr)
-+
-+#define EMIT_VERTS(ctx, j, nr, buf) \
-+	_tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
-+
-+#define TAG(x) glamo_##x
-+#include "tnl_dd/t_dd_dmatmp.h"
-+
-+
-+/**********************************************************************/
-+/*                          Render pipeline stage                     */
-+/**********************************************************************/
-+
-+static void glamoFireEngine(struct glamo_context *gCtx)
-+{
-+	glamoDRMStartBurst(gCtx, G3D_FIRE);
-+	glamoDRMAddData(gCtx, 0, 2);  /* Fire! */
-+	glamoDRMDispatch(gCtx);
-+}
-+
-+
-+static GLboolean glamoRunRender(GLcontext *ctx,
-+                                struct tnl_pipeline_stage *stage)
-+{
-+	TNLcontext *tnl = TNL_CONTEXT(ctx);
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	struct vertex_buffer *VB = &tnl->vb;
-+	GLuint i;
-+
-+	printf("glamoRunRender\n");
-+
-+	/* Don't handle clipping */
-+	if ( !glamo_validate_render(ctx, VB) ) {
-+		return GL_TRUE; /* Failed */
-+	}
-+
-+	/* Validate GPU state */
-+	if ( gCtx->new_state ) {
-+		if ( !glamoValidateState(ctx, gCtx->new_state) ) {
-+			printf("Couldn't validate state...\n");
-+		}
-+	} /* else nothing to update */
-+
-+	tnl->clipspace.new_inputs |= VERT_BIT_POS;
-+
-+	tnl->Driver.Render.Start(ctx);
-+
-+	for ( i=0; i<VB->PrimitiveCount; i++ ) {
-+
-+		GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
-+		GLuint start = VB->Primitive[i].start;
-+		GLuint length = VB->Primitive[i].count;
-+
-+		if (!length) continue;
-+
-+		glamo_render_tab_verts[prim & PRIM_MODE_MASK](ctx, start,
-+                                                     start + length, prim);
-+
-+	}
-+
-+	tnl->Driver.Render.Finish(ctx);
-+
-+	glamoFireEngine(gCtx);
-+
-+	return GL_FALSE;  /* Ok */
-+}
-+
-+
-+static const struct tnl_pipeline_stage _glamo_render_stage = {
-+	"glamo render",
-+	NULL,
-+	NULL,
-+	NULL,
-+	NULL,
-+	glamoRunRender
-+};
-+
-+
-+const struct tnl_pipeline_stage *glamo_pipeline[] = {
-+	&_tnl_vertex_transform_stage,
-+	&_tnl_vertex_cull_stage,
-+	&_tnl_normal_transform_stage,
-+	&_tnl_lighting_stage,
-+	&_tnl_fog_coordinate_stage,
-+	&_tnl_texgen_stage,
-+	&_tnl_texture_transform_stage,
-+	&_tnl_point_attenuation_stage,
-+	&_tnl_vertex_program_stage,
-+	&_glamo_render_stage,        /* ADD: unclipped rastersetup-to-dma */
-+	&_tnl_render_stage,
-+	0,
-+};
-diff --git a/src/mesa/drivers/dri/glamo/glamo_render.h b/src/mesa/drivers/dri/glamo/glamo_render.h
-new file mode 100644
-index 0000000..99c36a8
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_render.h
-@@ -0,0 +1,31 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_RENDER_H
-+#define __GLAMO_RENDER_H
-+
-+#include "main/mtypes.h"
-+
-+extern const struct tnl_pipeline_stage *glamo_pipeline[];
-+
-+#endif   /* __GLAMO_RENDER_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
-new file mode 100644
-index 0000000..39148f3
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
-@@ -0,0 +1,250 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_screen.c (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "dri_util.h"
-+#include "utils.h"
-+#include "xmlconfig.h"
-+#include "GL/internal/dri_interface.h"
-+#include "main/framebuffer.h"
-+#include "main/renderbuffer.h"
-+
-+#include "glamo_screen.h"
-+#include "glamo_context.h"
-+#include "glamo_fbo.h"
-+
-+/* This comes from libdrm_glamo */
-+#include <glamo_bo_gem.h>
-+
-+
-+static int glamoInitDriver(__DRIscreen *psp)
-+{
-+   return 0;
-+}
-+
-+
-+static glamoScreenPtr glamoCreateScreen(__DRIscreen *sPriv)
-+{
-+   glamoScreenPtr glamoScreen;
-+
-+   /* Allocate the private area */
-+   glamoScreen = (glamoScreenPtr)CALLOC(sizeof(*glamoScreen));
-+   if ( glamoScreen == NULL )
-+      return NULL;
-+
-+   glamoScreen->driScreen = sPriv;
-+
-+   /* This is our link to the kernel's memory manager, via libdrm */
-+   glamoScreen->bom = glamo_bo_manager_gem_ctor(sPriv->fd);
-+
-+   return glamoScreen;
-+}
-+
-+
-+static void glamoDestroyScreen(__DRIscreen *sPriv)
-+{
-+   glamoScreenPtr glamoScreen = (glamoScreenPtr)sPriv->private;
-+
-+   if ( glamoScreen == NULL )
-+      return;
-+
-+   FREE(glamoScreen);
-+   sPriv->private = NULL;
-+}
-+
-+
-+static const __DRIconfig **glamoInitScreen(__DRIscreen *sPriv)
-+{
-+   __DRIconfig **configs;
-+   uint8_t depth_bits_array[2];
-+   uint8_t stencil_bits_array[2];
-+   uint8_t msaa_samples_array[1];
-+   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
-+
-+   /* Driver initialisation */
-+   if ( glamoInitDriver(sPriv) ) {
-+      return NULL;
-+   }
-+
-+   /* Screen-specific initialisation */
-+   sPriv->private = glamoCreateScreen(sPriv);
-+   if ( !sPriv->private ) {
-+      glamoDestroyScreen(sPriv);
-+      return NULL;
-+   }
-+
-+   depth_bits_array[0] = 0;
-+   stencil_bits_array[0] = 0;
-+   depth_bits_array[1] = 16;
-+   stencil_bits_array[1] = 0;
-+   msaa_samples_array[0] = 0;
-+
-+   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-+                           depth_bits_array, stencil_bits_array, 2,
-+                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
-+
-+   if ( configs == NULL ) {
-+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
-+      return NULL;
-+   }
-+
-+   return (const __DRIconfig **)configs;
-+}
-+
-+
-+static const __DRIconfig **glamoInitScreen2(__DRIscreen *sPriv)
-+{
-+   __DRIconfig **configs;
-+   uint8_t depth_bits_array[2];
-+   uint8_t stencil_bits_array[2];
-+   uint8_t msaa_samples_array[1];
-+   static const GLenum db_modes[] = { GLX_SWAP_COPY_OML, GLX_NONE };
-+
-+   /* Driver initialisation */
-+   if ( glamoInitDriver(sPriv) ) {
-+      return NULL;
-+   }
-+
-+   /* Screen-specific initialisation */
-+   sPriv->private = glamoCreateScreen(sPriv);
-+   if ( !sPriv->private ) {
-+      glamoDestroyScreen(sPriv);
-+      return NULL;
-+   }
-+
-+   depth_bits_array[0] = 0;
-+   stencil_bits_array[0] = 0;
-+   depth_bits_array[1] = 16;
-+   stencil_bits_array[1] = 0;
-+   msaa_samples_array[0] = 0;
-+
-+   configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-+                           depth_bits_array, stencil_bits_array, 2,
-+                           db_modes, 2, msaa_samples_array, 1, GL_TRUE);
-+
-+   if ( configs == NULL ) {
-+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
-+      return NULL;
-+   }
-+
-+   return (const __DRIconfig **)configs;
-+}
-+
-+
-+/* Allocate buffers for a context.  This is where the fun starts... */
-+static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
-+                                   __DRIdrawable *driDrawPriv,
-+                                   const __GLcontextModes *mesaVis,
-+                                   GLboolean isPixmap)
-+{
-+   struct glamo_framebuffer *gfb;
-+   GLenum rgbFormat;
-+
-+   if ( isPixmap ) return GL_FALSE; /* not implemented */
-+
-+   gfb = CALLOC_STRUCT(glamo_framebuffer);
-+   if ( !gfb ) return GL_FALSE;
-+
-+   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
-+
-+   /* we only support this one format at the moment */
-+   rgbFormat = GL_RGB5;
-+
-+   /* Front color renderbuffer */
-+   gfb->color_rb[0] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
-+   _mesa_add_renderbuffer(&gfb->base, BUFFER_FRONT_LEFT,
-+                          &gfb->color_rb[0]->base);
-+
-+   /* Back color renderbuffer, if requested */
-+   if ( mesaVis->doubleBufferMode ) {
-+      gfb->color_rb[1] = glamo_create_renderbuffer(rgbFormat, driDrawPriv);
-+      _mesa_add_renderbuffer(&gfb->base, BUFFER_BACK_LEFT,
-+                             &gfb->color_rb[1]->base);
-+   }
-+
-+   if ( mesaVis->depthBits == 16 ) {
-+      struct glamo_renderbuffer *depth;
-+      depth = glamo_create_renderbuffer(GL_DEPTH_COMPONENT16, driDrawPriv);
-+      _mesa_add_renderbuffer(&gfb->base, BUFFER_DEPTH, &depth->base);
-+   }
-+
-+   /* Add software renderbuffers for the things we can't support in hardware */
-+   _mesa_add_soft_renderbuffers(&gfb->base,
-+      GL_FALSE,  /* color */
-+      GL_FALSE,  /* depth */
-+      mesaVis->stencilBits > 0,   /* stencil, if required */
-+      mesaVis->accumRedBits > 0,  /* accum, if required */
-+      GL_FALSE,  /* alpha */
-+      GL_FALSE   /* aux */
-+   );
-+   driDrawPriv->driverPrivate = (void *)gfb;
-+
-+   return (driDrawPriv->driverPrivate != NULL);
-+}
-+
-+
-+static void glamoDestroyBuffer(__DRIdrawable *driDrawPriv)
-+{
-+}
-+
-+
-+static void glamoSwapBuffers(__DRIdrawable *driDrawPriv)
-+{
-+   printf("glamoSwapBuffers\n"); fflush(stdout);
-+}
-+
-+
-+/*
-+ *  Mesa entry points
-+ *
-+ *  See src/mesa/drivers/dri/common/dri_util.h for information about these
-+ */
-+const struct __DriverAPIRec driDriverAPI = {
-+   .InitScreen      = glamoInitScreen,
-+   .DestroyScreen   = glamoDestroyScreen,
-+   .CreateContext   = glamoCreateContext,
-+   .DestroyContext  = glamoDestroyContext,
-+   .CreateBuffer    = glamoCreateBuffer,
-+   .DestroyBuffer   = glamoDestroyBuffer,
-+   .SwapBuffers     = glamoSwapBuffers,
-+   .MakeCurrent     = glamoMakeCurrent,
-+   .UnbindContext   = glamoUnbindContext,
-+   .GetSwapInfo     = NULL,   /* Not used */
-+   .WaitForMSC      = NULL,
-+   .WaitForSBC      = NULL,
-+   .SwapBuffersMSC  = NULL,
-+   .CopySubBuffer   = NULL,
-+   .GetDrawableMSC  = NULL,   /* Not used */
-+   .InitScreen2     = glamoInitScreen2,    /* For DRI2 */
-+};
-+
-+/* This is the table of extensions that the loader will dlsym() for. */
-+PUBLIC const __DRIextension *__driDriverExtensions[] = {
-+    &driCoreExtension.base,
-+    &driLegacyExtension.base,
-+    &driDRI2Extension.base,
-+    NULL
-+};
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.h b/src/mesa/drivers/dri/glamo/glamo_screen.h
-new file mode 100644
-index 0000000..3f2eb5f
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.h
-@@ -0,0 +1,44 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_screen.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_SCREEN_H
-+#define __GLAMO_SCREEN_H
-+
-+#include "xmlconfig.h"
-+#include "dri_util.h"
-+
-+#include <glamo_bo_gem.h>
-+
-+typedef struct {
-+
-+   __DRIscreen *driScreen;
-+   driOptionCache optionCache;
-+
-+   struct glamo_bo_manager *bom;
-+
-+} glamoScreenRec, *glamoScreenPtr;
-+
-+#endif   /* __GLAMO_SCREEN_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_state.c b/src/mesa/drivers/dri/glamo/glamo_state.c
-new file mode 100644
-index 0000000..4046c24
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_state.c
-@@ -0,0 +1,304 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009-2010 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_state.c (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Also partially based on intel_fbo.c, to which the following notice applies:
-+ *
-+ * Copyright 2006 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+
-+#include "main/context.h"
-+#include "main/framebuffer.h"
-+#include "main/api_arrayelt.h"
-+#include "swrast/swrast.h"
-+#include "swrast_setup/swrast_setup.h"
-+#include "tnl/tnl.h"
-+
-+#include "glamo_fbo.h"
-+#include "glamo_state.h"
-+#include "glamo_context.h"
-+#include "glamo_cmdq.h"
-+#include "glamo_regs.h"
-+
-+
-+static void glamoResizeBuffers(GLcontext *ctx, struct gl_framebuffer *fb,
-+                               GLuint width, GLuint height)
-+{
-+	struct glamo_framebuffer *glamo_fb = (struct glamo_framebuffer *)fb;
-+	int i;
-+
-+	_mesa_resize_framebuffer(ctx, fb, width, height);
-+
-+	fb->Initialized = GL_TRUE; /* XXX remove someday */
-+
-+	if (fb->Name != 0) {
-+		return;
-+	}
-+
-+	/* Make sure all window system renderbuffers are up to date */
-+	for (i = 0; i < 2; i++) {
-+		struct gl_renderbuffer *rb = &glamo_fb->color_rb[i]->base;
-+
-+		/* only resize if size is changing */
-+		if (rb && (rb->Width != width || rb->Height != height)) {
-+			rb->AllocStorage(ctx, rb, rb->InternalFormat,
-+		                         width, height);
-+		}
-+	}
-+}
-+
-+
-+static void glamoClear(GLcontext *ctx, GLbitfield mask)
-+{
-+	glamoContext *gCtx;
-+	struct gl_framebuffer *fb;
-+	int i;
-+
-+	gCtx = GLAMO_CONTEXT(ctx);
-+	fb = ctx->DrawBuffer;
-+
-+	printf("glamoClear (%f %f %f %f)\n", ctx->Color.ClearColor[0],
-+	       ctx->Color.ClearColor[1], ctx->Color.ClearColor[2],
-+	       ctx->Color.ClearColor[3]); fflush(stdout);
-+
-+	for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
-+
-+		struct glamo_renderbuffer *grb;
-+
-+		grb = glamo_renderbuffer(fb->_ColorDrawBuffers[i]);
-+
-+		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_DST_X);
-+		glamoDRMAddData(gCtx, fb->_Xmin, 2);           /* dest X */
-+		glamoDRMAddData(gCtx, fb->_Ymin, 2);           /* dest Y */
-+		glamoDRMAddBO(gCtx, grb->bo);                  /* dest L/H */
-+		glamoDRMAddData(gCtx, grb->pitch & 0x7ff, 2);  /* dest pitch */
-+		glamoDRMAddData(gCtx, grb->height, 2);         /* dest height */
-+		glamoDRMAddData(gCtx, fb->_Xmax-fb->_Xmin, 2); /* width */
-+		glamoDRMAddData(gCtx, fb->_Ymax-fb->_Ymin, 2); /* height */
-+		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt L */
-+		glamoDRMAddData(gCtx, 0x0000, 2);              /* patt H */
-+		glamoDRMAddData(gCtx, gCtx->col_clear, 2);     /* FG colour */
-+		glamoDRMDispatch(gCtx);
-+
-+		glamoDRMStartBurst(gCtx, GLAMO_REG_2D_COMMAND1);
-+		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 1 */
-+		glamoDRMAddData(gCtx, 0xf0 << 8, 2); /* Cmd param 2 */
-+		glamoDRMAddData(gCtx, 0x0000, 2);    /* Cmd param 3 */
-+		glamoDRMDispatch(gCtx);
-+
-+	}
-+}
-+
-+
-+static void glamoClearColor(GLcontext *ctx, const GLfloat color[4])
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	GLubyte col_byte[4];
-+
-+	printf("glamoClearColor (%f %f %f %f)\n", color[0], color[1], color[2],
-+	       color[3]); fflush(stdout);
-+
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[0], color[0]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[1], color[1]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[2], color[2]);
-+	CLAMPED_FLOAT_TO_UBYTE(col_byte[3], color[3]);
-+
-+	gCtx->col_clear = GLAMO_PACKCOLOR565(col_byte[0], col_byte[1],
-+	                                     col_byte[2]);
-+}
-+
-+
-+static void glamoShadeModel(GLcontext *ctx, GLenum mode)
-+{
-+	printf("glamoShadeModel\n"); fflush(stdout);
-+}
-+
-+
-+static void glamoViewport(GLcontext *ctx, GLint x, GLint y,
-+                          GLsizei width, GLsizei height )
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	__DRIcontext *driContext = gCtx->driContext;
-+	void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
-+			 GLsizei w, GLsizei h);
-+
-+	if ( !driContext->driScreenPriv->dri2.enabled ) return;
-+
-+	/* TODO: Flush before fiddling with fake front buffer */
-+
-+	if ( ctx->DrawBuffer->Name == 0 ) {
-+
-+		glamo_update_renderbuffers(driContext,
-+		                           driContext->driDrawablePriv);
-+		if ( driContext->driDrawablePriv
-+		                              != driContext->driReadablePriv ) {
-+			glamo_update_renderbuffers(driContext,
-+				                   driContext->driReadablePriv);
-+		}
-+
-+	}
-+
-+	old_viewport = ctx->Driver.Viewport;
-+	ctx->Driver.Viewport = NULL;
-+	gCtx->driDrawable = driContext->driDrawablePriv;
-+	ctx->Driver.Viewport = old_viewport;
-+}
-+
-+
-+static void glamoUploadMatrix(struct glamo_context *gCtx, uint16_t mreg,
-+                              GLfloat *matrix)
-+{
-+	int i;
-+	char *type;
-+
-+	switch ( mreg ) {
-+	case G3D_MATRIX_MVP :
-+		type = "MVP"; break;
-+	case G3D_MATRIX_MV :
-+		type = "MV"; break;
-+	case G3D_MATRIX_IMVP :
-+		type = "inverse MVP"; break;
-+	default :
-+		type = "unknown"; break;
-+	}
-+	printf("Uploading %s matrix...\n", type);
-+
-+	glamoDRMStartBurst(gCtx, mreg);
-+	if ( mreg != G3D_MATRIX_IMVP ) {
-+		for ( i=0; i<16; i++ ) {
-+			glamoDRMAddData(gCtx, float7s16(matrix[i]), 4);
-+		}
-+	} else {
-+		/* Normal matrix needs special treatment */
-+		for ( i=0; i<3; i++ ) {
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i]), 4);
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i+1]), 4);
-+			glamoDRMAddData(gCtx, float7s16(matrix[4*i+2]), 4);
-+		}
-+	}
-+	glamoDRMDispatch(gCtx);
-+}
-+
-+
-+GLboolean glamoValidateState(GLcontext *ctx, GLuint new_state)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	if ( new_state & (_NEW_MODELVIEW|_NEW_PROJECTION) ) {
-+
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_MVP,
-+		                  ctx->_ModelProjectMatrix.m);
-+
-+		/* FIXME: The following two aren't needed unless lighting
-+		 * is in use... */
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_MV,
-+		                  ctx->ModelviewMatrixStack.Top->m);
-+		_math_matrix_alloc_inv(&(ctx->_ModelProjectMatrix));
-+		_math_matrix_analyse(&(ctx->_ModelProjectMatrix));
-+		glamoUploadMatrix(gCtx, G3D_MATRIX_IMVP,
-+		                  ctx->_ModelProjectMatrix.inv);
-+	}
-+
-+	gCtx->new_state = 0;
-+	return GL_TRUE;
-+}
-+
-+
-+static void glamoUpdateState(GLcontext *ctx, GLbitfield new_state)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	printf("glamoUpdateState\n");
-+
-+	_swrast_InvalidateState(ctx, new_state);
-+	_swsetup_InvalidateState(ctx, new_state);
-+	_vbo_InvalidateState(ctx, new_state);
-+	_tnl_InvalidateState(ctx, new_state);
-+	_ae_invalidate_state(ctx, new_state);
-+
-+	/* Make a note that some state has changed,
-+	 * so that it can be sent to the GPU later. */
-+	gCtx->new_state |= new_state;
-+}
-+
-+
-+static void glamoFlush(GLcontext *ctx)
-+{
-+	printf("glamoFlush\n");
-+}
-+
-+
-+void glamoInitStateFuncs(GLcontext *ctx)
-+{
-+	ctx->Driver.UpdateState       = glamoUpdateState;
-+	ctx->Driver.Clear             = glamoClear;
-+	ctx->Driver.ClearColor        = glamoClearColor;
-+	ctx->Driver.ClearDepth        = NULL;
-+	ctx->Driver.ClearStencil      = NULL;
-+	ctx->Driver.AlphaFunc         = NULL;
-+	ctx->Driver.BlendFuncSeparate = NULL;
-+	ctx->Driver.ColorMask         = NULL;
-+	ctx->Driver.CullFace          = NULL;
-+	ctx->Driver.DepthMask         = NULL;
-+	ctx->Driver.DepthFunc         = NULL;
-+	ctx->Driver.DepthRange        = NULL;
-+	ctx->Driver.DrawBuffer        = NULL;
-+	ctx->Driver.Enable            = NULL;
-+	ctx->Driver.FrontFace         = NULL;
-+	ctx->Driver.Fogfv             = NULL;
-+	ctx->Driver.Hint              = NULL;
-+	ctx->Driver.Lightfv           = NULL;
-+	ctx->Driver.LogicOpcode       = NULL;
-+	ctx->Driver.PolygonMode       = NULL;
-+	ctx->Driver.PolygonStipple    = NULL;
-+	ctx->Driver.ReadBuffer        = NULL;
-+	ctx->Driver.RenderMode        = NULL;
-+	ctx->Driver.Scissor           = NULL;
-+	ctx->Driver.ShadeModel        = glamoShadeModel;
-+	ctx->Driver.LightModelfv      = NULL;
-+	ctx->Driver.Viewport          = glamoViewport;
-+	ctx->Driver.ResizeBuffers     = glamoResizeBuffers;
-+	ctx->Driver.Flush             = glamoFlush;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_state.h b/src/mesa/drivers/dri/glamo/glamo_state.h
-new file mode 100644
-index 0000000..98f0b97
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_state.h
-@@ -0,0 +1,34 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ * Roughly based on sis_state.h (c) 2003 Eric Anholt
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_STATE_H
-+#define __GLAMO_STATE_H
-+
-+#include "main/context.h"
-+
-+extern void glamoInitStateFuncs(GLcontext *ctx);
-+
-+#endif   /* __GLAMO_STATE_H */
-+
-+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.c b/src/mesa/drivers/dri/glamo/glamo_tris.c
-new file mode 100644
-index 0000000..6c6b5a6
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_tris.c
-@@ -0,0 +1,310 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS 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.
-+ *
-+ *
-+ * Based on intel_tris.c, to which the following notice applies:
-+ *
-+ * Copyright 2003 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, 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 TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ *
-+ */
-+
-+
-+#include <glamo_bo.h>
-+#include <glamo_bo_gem.h>
-+#include <glamo_drm.h>
-+
-+#include "main/mtypes.h"
-+#include "swrast/swrast.h"
-+#include "tnl/t_context.h"
-+#include "tnl/t_vertex.h"
-+#include "tnl/t_pipeline.h"
-+
-+#include "glamo_tris.h"
-+#include "glamo_context.h"
-+
-+
-+static void glamoRunPipeline(GLcontext *ctx)
-+{
-+	printf("glamoRunPipeline\n");
-+
-+	/* TODO: Emit state */
-+
-+	_tnl_run_pipeline(ctx);
-+}
-+
-+
-+static void glamoRenderStart(GLcontext *ctx)
-+{
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+
-+	/* Decide which attributes will be used */
-+	gCtx->vertex_attrs[0].attrib = _TNL_ATTRIB_POS;
-+	gCtx->vertex_attrs[0].format = EMIT_4F;
-+
-+	gCtx->vertex_size = _tnl_install_attrs(ctx, gCtx->vertex_attrs, 1,
-+	                                       NULL, 0);
-+}
-+
-+
-+static void glamoRenderFinish(GLcontext *ctx)
-+{
-+	printf("glamoRenderFinish\n");
-+}
-+
-+
-+static void glamoPrimitiveNotify(GLcontext *ctx, GLenum prim)
-+{
-+	printf("glamoPrimitiveNotify\n");
-+}
-+
-+
-+uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx, unsigned int count)
-+{
-+	uint32_t *addr;
-+
-+	printf("glamoGetPrimSpace\n");
-+
-+	/* Check for space in the existing VB */
-+	if (gCtx->prim.vb_bo == NULL || (gCtx->prim.current_offset +
-+	                           count * gCtx->vertex_size) > GLAMO_VB_SIZE) {
-+
-+		/* Not enough space, or no VB existing. Start a new one... */
-+		if (gCtx->prim.vb == NULL) {
-+			printf("Allocated %i bytes\n", GLAMO_VB_SIZE);
-+			gCtx->prim.vb = malloc(GLAMO_VB_SIZE);
-+		}
-+		gCtx->prim.vb_bo = glamo_bo_open(gCtx->glamoScreen->bom, 0,
-+		                                 GLAMO_VB_SIZE, 4,
-+		                                 GLAMO_GEM_DOMAIN_VRAM, 0);
-+		gCtx->prim.start_offset = 0;
-+		gCtx->prim.current_offset = 0;
-+	}
-+
-+	addr = (uint32_t *)(gCtx->prim.vb + gCtx->prim.current_offset);
-+	gCtx->prim.current_offset += gCtx->vertex_size * count;
-+	gCtx->prim.count += count;
-+
-+	return addr;
-+}
-+
-+
-+#define COPY_DWORDS( j, vb, vertsize, v )	\
-+do {						\
-+   for ( j = 0 ; j < vertsize ; j++ ) {		\
-+      vb[j] = ((GLuint *)v)[j];			\
-+   }						\
-+   vb += vertsize;				\
-+} while (0)
-+
-+
-+static void glamo_draw_triangle(struct glamo_context *gCtx,
-+                                glamoVertexPtr v0, glamoVertexPtr v1,
-+                                glamoVertexPtr v2)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 3);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v2);
-+}
-+
-+
-+static void glamo_draw_line(struct glamo_context *gCtx,
-+                            glamoVertexPtr v0, glamoVertexPtr v1)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v1);
-+}
-+
-+
-+static void glamo_draw_point(struct glamo_context *gCtx, glamoVertexPtr v0)
-+{
-+	GLuint *vb = glamoGetPrimSpace(gCtx, 2);
-+	int j;
-+
-+	COPY_DWORDS(j, vb, gCtx->vertex_size, v0);
-+}
-+
-+
-+#define TRI( a, b, c )                          \
-+do {                                            \
-+        glamo_draw_triangle(gCtx, a, b, c  );   \
-+} while (0)
-+
-+
-+#define QUAD( a, b, c, d )                      \
-+printf("Drawing a quad\n");                     \
-+do {                                            \
-+        glamo_draw_triangle(gCtx, a, b, d);     \
-+        glamo_draw_triangle(gCtx, b, c, d);     \
-+} while (0)
-+
-+
-+#define LINE(v0, v1)                            \
-+do {                                            \
-+        glamo_draw_line(gCtx, v0, v1);          \
-+} while (0)
-+
-+
-+#define POINT(v0)                               \
-+do {                                            \
-+        glamo_draw_point(gCtx, v0);             \
-+} while (0)
-+
-+
-+#define IND (0)
-+#define TAG(x) x
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_unfilled
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_offset_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+#define IND (0)
-+#define TAG(x) x##_twoside_offset_unfilled_fallback
-+#include "tnl_dd/t_dd_tritmp.h"
-+
-+
-+static void init_rast_tab()
-+{
-+	init();
-+	init_offset();
-+	init_twoside();
-+	init_twoside_offset();
-+	init_unfilled();
-+	init_offset_unfilled();
-+	init_twoside_unfilled();
-+	init_twoside_offset_unfilled();
-+	init_fallback();
-+	init_offset_fallback();
-+	init_twoside_fallback();
-+	init_twoside_offset_fallback();
-+	init_unfilled_fallback();
-+	init_offset_unfilled_fallback();
-+	init_twoside_unfilled_fallback();
-+	init_twoside_offset_unfilled_fallback();
-+}
-+
-+
-+void glamoInitTriFuncs(GLcontext *ctx)
-+{
-+	TNLcontext *tnl = TNL_CONTEXT(ctx);
-+	struct glamo_context *gCtx = GLAMO_CONTEXT(ctx);
-+	static int firsttime = 1;
-+
-+	if (firsttime) {
-+		init_rast_tab();
-+		firsttime = 0;
-+	}
-+
-+	gCtx->prim.start_offset = 0;
-+	gCtx->prim.current_offset = 0;
-+	gCtx->prim.vb_bo = NULL;
-+	gCtx->prim.vb = NULL;
-+	gCtx->prim.count = 0;
-+
-+	tnl->Driver.RunPipeline = glamoRunPipeline;
-+	tnl->Driver.Render.Start = glamoRenderStart;
-+	tnl->Driver.Render.Finish = glamoRenderFinish;
-+	tnl->Driver.Render.PrimitiveNotify = glamoPrimitiveNotify;
-+	tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
-+	tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
-+	tnl->Driver.Render.CopyPV = _tnl_copy_pv;
-+	tnl->Driver.Render.Interp = _tnl_interp;
-+}
-diff --git a/src/mesa/drivers/dri/glamo/glamo_tris.h b/src/mesa/drivers/dri/glamo/glamo_tris.h
-new file mode 100644
-index 0000000..ba8f997
---- /dev/null
-+++ b/src/mesa/drivers/dri/glamo/glamo_tris.h
-@@ -0,0 +1,38 @@
-+/*
-+ * Direct Rendering Support for SMedia Glamo 336x/337x
-+ *
-+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice shall be included
-+ * in all copies or substantial portions of the Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-+ */
-+
-+#ifndef __GLAMO_TRIS_H
-+#define __GLAMO_TRIS_H
-+
-+#include "main/mtypes.h"
-+
-+#include "glamo_context.h"
-+
-+/* Amount of space reserved for vertex submission */
-+#define GLAMO_VB_SIZE (32*1024)
-+
-+extern void glamoInitTriFuncs(GLcontext *ctx);
-+extern uint32_t *glamoGetPrimSpace(struct glamo_context *gCtx,
-+                                   unsigned int count);
-+
-+#endif   /* __GLAMO_TRIS_H */
-diff --git a/src/mesa/drivers/dri/glamo/glamo_screen.c b/src/mesa/drivers/dri/glamo/glamo_screen.c
-index 39148f3..8244ec3 100644
---- a/src/mesa/drivers/dri/glamo/glamo_screen.c
-+++ b/src/mesa/drivers/dri/glamo/glamo_screen.c
-@@ -166,7 +166,7 @@ static GLboolean glamoCreateBuffer(__DRIscreen *driScrnPriv,
-    gfb = CALLOC_STRUCT(glamo_framebuffer);
-    if ( !gfb ) return GL_FALSE;
- 
--   _mesa_initialize_framebuffer(&gfb->base, mesaVis);
-+   _mesa_initialize_window_framebuffer(&gfb->base, mesaVis);
- 
-    /* we only support this one format at the moment */
-    rgbFormat = GL_RGB5;
diff --git a/recipes/mesa/mesa-dri.inc b/recipes/mesa/mesa-dri.inc
new file mode 100644
index 0000000..33258c5
--- /dev/null
+++ b/recipes/mesa/mesa-dri.inc
@@ -0,0 +1,8 @@
+DEPENDS += "dri2proto expat libdrm makedepend-native"
+
+FILESPATHPKG =. "mesa-${PV}:mesa:"
+
+# most of our targets do not have DRI so will use mesa-xlib
+DEFAULT_PREFERENCE = "-1"
+
+EXTRA_OECONF += " --with-driver=dri --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
diff --git a/recipes/mesa/mesa-dri_7.2.bb b/recipes/mesa/mesa-dri_7.2.bb
index da402c3..26b56e4 100644
--- a/recipes/mesa/mesa-dri_7.2.bb
+++ b/recipes/mesa/mesa-dri_7.2.bb
@@ -1,27 +1,4 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto expat"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
+require mesa-common.inc
+require mesa-${PV}.inc
+require mesa-dri.inc
 PR = "${INC_PR}.0"
-
-# most of our targets do not have DRI so will use mesa-xlib
-DEFAULT_PREFERENCE = "-1"
-
-# ASUS EeePC 901 has DRI support so use mesa-dri by default
-DEFAULT_PREFERENCE_eee901 = "1"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN} += "${libdir}/dri/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-EXTRA_OECONF += "--with-driver=dri --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-
-SRC_URI[archive.md5sum] = "04d379292e023df0b0266825cb0dbde5"
-SRC_URI[archive.sha256sum] = "a9cc62ab760afeebcb1319a193508734a2d470cab8effab2776a2d3c65bd9cd2"
-SRC_URI[demos.md5sum] = "22e03dc4038cd63f32c21eb60994892b"
-SRC_URI[demos.sha256sum] = "3d73988ad3e87f6084a4593cc6b3aac63aca3e893d3e9409d892a6f51558e4c4"
diff --git a/recipes/mesa/mesa-dri_7.6.bb b/recipes/mesa/mesa-dri_7.6.bb
index 33f4069..26b56e4 100644
--- a/recipes/mesa/mesa-dri_7.6.bb
+++ b/recipes/mesa/mesa-dri_7.6.bb
@@ -1,32 +1,4 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto expat"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-          "
+require mesa-common.inc
+require mesa-${PV}.inc
+require mesa-dri.inc
 PR = "${INC_PR}.0"
-
-# most of our targets do not have DRI so will use mesa-xlib
-DEFAULT_PREFERENCE = "-1"
-
-DEFAULT_PREFERENCE_om-gta01 = "2"
-
-# ASUS EeePC 901 has DRI support so use mesa-dri by default
-DEFAULT_PREFERENCE_eee901 = "1"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN} += "${libdir}/dri/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-EXTRA_OECONF += "--disable-gallium --with-driver=dri --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-
-SRC_URI[archive.md5sum] = "8c75f90cd0303cfac9e4b6d54f6759ca"
-SRC_URI[archive.sha256sum] = "782a7b2810b1c466b3a994eba96485b59b47cc1120c0caa24de1aecf1e013830"
-SRC_URI[demos.md5sum] = "0ede7adf217951acd90dbe4551210c07"
-SRC_URI[demos.sha256sum] = "2fdf09fd7967fb1946e7f6af07d39c9fb695c373e1bad3855d3c3fbece5badd0"
diff --git a/recipes/mesa/mesa-dri_7.8.2.bb b/recipes/mesa/mesa-dri_7.8.2.bb
index 356c284..8c4cef6 100644
--- a/recipes/mesa/mesa-dri_7.8.2.bb
+++ b/recipes/mesa/mesa-dri_7.8.2.bb
@@ -1,41 +1,9 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto expat"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS} makedepend-native mesa-dri-glsl-native"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-	   file://fix-progs-makefile.patch \
-	   file://glamo.patch \
-          "
-SRC_URI[archive.md5sum] = "6be2d343a0089bfd395ce02aaf8adb57"
-SRC_URI[archive.sha256sum] = "505bf418dceba05837f4ea1b1972b9620c35f8cb94bc4d1e6d573c15f562576d"
-SRC_URI[demos.md5sum] = "757d9e2e06f48b1a52848be9b0307ced"
-SRC_URI[demos.sha256sum] = "ea7b9ebfb7a80de2b275c0c9124c8a505382ec48411a2794ab82542f9885ac3c"
-
+require mesa-common.inc
+require mesa-${PV}.inc
+require mesa-dri.inc
 PR = "${INC_PR}.0"
 
-# most of our targets do not have DRI so will use mesa-xlib
-DEFAULT_PREFERENCE = "-1"
-DEFAULT_PREFERENCE_shr = "2"
-
-# ASUS EeePC 901 has DRI support so use mesa-dri by default
-DEFAULT_PREFERENCE_eee901 = "1"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN} += "${libdir}/dri/*.so \
-                ${libdir}/egl/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/* \
-                    ${libdir}/egl/.debug/*"
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-EXTRA_OECONF += "--with-driver=dri --disable-glx-tls --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-EXTRA_OECONF_shr += "--with-driver=dri --disable-glx-tls --disable-gallium \
- --disable-gallium-intel --with-dri-drivers=swrast,${MACHINE_DRI_MODULES} \
- ${@base_conditional( 'MACHINE',"htcdream", "--disable-egl", "",d)} "
+DEPENDS += "mesa-dri-glsl-native"
 
 # We need glsl-compile built for buildhost arch instead of target (is provided by mesa-dri-glsl-native)"
 do_configure_prepend() {
diff --git a/recipes/mesa/mesa-dri_git.bb b/recipes/mesa/mesa-dri_git.bb
index 5f72641..61fb199 100644
--- a/recipes/mesa/mesa-dri_git.bb
+++ b/recipes/mesa/mesa-dri_git.bb
@@ -1,16 +1,11 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto dri2proto"
-LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes expat"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS} makedepend-native mesa-dri-glsl-native"
+require mesa-common.inc
+require mesa-dri.inc
 
 PV = "7.7.999"
 PR = "${INC_PR}.0"
 PR_append = "+gitr${SRCPV}"
 
 DEFAULT_PREFERENCE = "-2"
-DEFAULT_PREFERENCE_shr = "2"
 
 SRCREV = "196214bf2b677a83653d49f79d03752f29df44ec"
 SRCREV_shr = "1ac166895fef47806c9e9286d2a6356b4db8398d"
@@ -22,15 +17,7 @@ SRC_URI_shr_append = " file://fix-progs-makefile.patch"
 
 S = "${WORKDIR}/git"
 
-PACKAGES =+ " mesa-utils "
-
-FILES_${PN} += "${libdir}/dri/*.so"
-FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
-FILES_mesa-utils = "${bindir}/*"
-
-EXTRA_OECONF += "--with-driver=dri --disable-glx-tls --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-EXTRA_OECONF_om-gta02 += "--with-driver=dri --disable-glx-tls --disable-gallium --disable-gallium-intel --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
-EXTRA_OECONF_om-gta01 += "--with-driver=dri --disable-glx-tls --disable-gallium --disable-gallium-intel --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
+DEPENDS += "mesa-dri-glsl-native"
 
 # We need glsl-compile built for buildhost arch instead of target (is provided by mesa-dri-glsl-native)"
 do_configure_prepend() {
diff --git a/recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch b/recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch
deleted file mode 100644
index 40e6a1b..0000000
--- a/recipes/mesa/mesa-xlib-7.8.2/fix-progs-makefile.patch
+++ /dev/null
@@ -1,81 +0,0 @@
-From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
-From: Martin Jansa <Martin.Jansa@gmail.com>
-Date: Thu, 4 Mar 2010 14:16:27 +0100
-Subject: [PATCH] fix libs
-
----
- progs/demos/Makefile   |    2 +-
- progs/glsl/Makefile    |    2 +-
- progs/redbook/Makefile |    2 +-
- progs/samples/Makefile |    2 +-
- progs/xdemos/Makefile  |    2 +-
- 5 files changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/progs/demos/Makefile b/progs/demos/Makefile
-index 5b1d2a0..121b862 100644
---- a/progs/demos/Makefile
-+++ b/progs/demos/Makefile
-@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
- 	$(APP_LIB_DEPS)
- 
- PROGS = \
-diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
-index 3b5a595..836c4ac 100644
---- a/progs/glsl/Makefile
-+++ b/progs/glsl/Makefile
-@@ -10,7 +10,7 @@ LIB_DEP = \
- 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
- 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
- 	-l$(GL_LIB) $(APP_LIB_DEPS)
- 
- # using : to avoid APP_CC pointing to CC loop
-diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
-index b41e488..95ed746 100644
---- a/progs/redbook/Makefile
-+++ b/progs/redbook/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = aaindex \
- 	aapoly \
-diff --git a/progs/samples/Makefile b/progs/samples/Makefile
-index 64fa47a..9f72c8b 100644
---- a/progs/samples/Makefile
-+++ b/progs/samples/Makefile
-@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
- 
- LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
- 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
-diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
-index f866a32..c0f4e06 100644
---- a/progs/xdemos/Makefile
-+++ b/progs/xdemos/Makefile
-@@ -11,7 +11,7 @@
- # Add X11 and pthread libs to satisfy GNU gold.
- APP_LIB_DEPS += -lX11 -lpthread
- 
--LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) $(APP_LIB_DEPS)
-+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) -lstdc++ $(APP_LIB_DEPS)
- 
- PROGS = \
- 	corender \
--- 
-1.7.0
-
diff --git a/recipes/mesa/mesa-xlib.inc b/recipes/mesa/mesa-xlib.inc
new file mode 100644
index 0000000..cabe6e5
--- /dev/null
+++ b/recipes/mesa/mesa-xlib.inc
@@ -0,0 +1,2 @@
+FILESPATHPKG =. "mesa-${PV}:mesa:"
+EXTRA_OECONF += " --with-driver=xlib"
diff --git a/recipes/mesa/mesa-xlib_7.2.bb b/recipes/mesa/mesa-xlib_7.2.bb
index dfc0d7c..93bb8cd 100644
--- a/recipes/mesa/mesa-xlib_7.2.bb
+++ b/recipes/mesa/mesa-xlib_7.2.bb
@@ -1,24 +1,4 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto"
-LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
+require mesa-common.inc
+require mesa-${PV}.inc
+require mesa-xlib.inc
 PR = "${INC_PR}.0"
-
-EXTRA_OECONF += "--with-driver=xlib"
-
-PACKAGES =+ "${PN}-xprogs"
-
-FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
-
-do_install_append () {
-    install -d ${D}/${bindir}
-    install -m 0755 ${S}/progs/xdemos/{glxdemo,glxgears,glxheads,glxinfo} ${D}/${bindir}
-}
-
-SRC_URI[archive.md5sum] = "04d379292e023df0b0266825cb0dbde5"
-SRC_URI[archive.sha256sum] = "a9cc62ab760afeebcb1319a193508734a2d470cab8effab2776a2d3c65bd9cd2"
-SRC_URI[demos.md5sum] = "22e03dc4038cd63f32c21eb60994892b"
-SRC_URI[demos.sha256sum] = "3d73988ad3e87f6084a4593cc6b3aac63aca3e893d3e9409d892a6f51558e4c4"
diff --git a/recipes/mesa/mesa-xlib_7.6.bb b/recipes/mesa/mesa-xlib_7.6.bb
index e81c585..93bb8cd 100644
--- a/recipes/mesa/mesa-xlib_7.6.bb
+++ b/recipes/mesa/mesa-xlib_7.6.bb
@@ -1,19 +1,4 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto"
-LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-          "
-
+require mesa-common.inc
+require mesa-${PV}.inc
+require mesa-xlib.inc
 PR = "${INC_PR}.0"
-
-EXTRA_OECONF += "--disable-gallium --with-driver=xlib"
-
-SRC_URI[archive.md5sum] = "8c75f90cd0303cfac9e4b6d54f6759ca"
-SRC_URI[archive.sha256sum] = "782a7b2810b1c466b3a994eba96485b59b47cc1120c0caa24de1aecf1e013830"
-SRC_URI[demos.md5sum] = "0ede7adf217951acd90dbe4551210c07"
-SRC_URI[demos.sha256sum] = "2fdf09fd7967fb1946e7f6af07d39c9fb695c373e1bad3855d3c3fbece5badd0"
diff --git a/recipes/mesa/mesa-xlib_7.8.2.bb b/recipes/mesa/mesa-xlib_7.8.2.bb
index 6c0e7ea..93bb8cd 100644
--- a/recipes/mesa/mesa-xlib_7.8.2.bb
+++ b/recipes/mesa/mesa-xlib_7.8.2.bb
@@ -1,20 +1,4 @@
-include mesa-common.inc
-
-PROTO_DEPS = "xf86driproto glproto"
-LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
-
-DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
-
-SRC_URI = "ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaLib-${PV}.tar.bz2;name=archive \
-           ftp://ftp.freedesktop.org/pub/mesa/${PV}/MesaDemos-${PV}.tar.bz2;name=demos \
-           file://fix-progs-makefile.patch \
-          "
-
-SRC_URI[archive.md5sum] = "85cb891eecb89aae4fdd3499cccd934b"
-SRC_URI[archive.sha256sum] = "8c85db5844303b806b18fc6bd40a9dccb02d90b54878a94f910674673ba0aa35"
-SRC_URI[demos.md5sum] = "9fe8ec184c7f78691e43c4c0a7f97d56"
-SRC_URI[demos.sha256sum] = "5bf65f03ddcd04b02e9ca044285f8754decee67eb274191da1f31627f1d84b0e"
-
+require mesa-common.inc
+require mesa-${PV}.inc
+require mesa-xlib.inc
 PR = "${INC_PR}.0"
-
-EXTRA_OECONF += "--disable-gallium --with-driver=xlib"
diff --git a/recipes/mesa/mesa/fix-progs-makefile.patch b/recipes/mesa/mesa/fix-progs-makefile.patch
new file mode 100644
index 0000000..f05d4b0
--- /dev/null
+++ b/recipes/mesa/mesa/fix-progs-makefile.patch
@@ -0,0 +1,82 @@
+From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
+From: Martin Jansa <Martin.Jansa@gmail.com>
+Date: Thu, 4 Mar 2010 14:16:27 +0100
+Subject: [PATCH] fix libs
+
+---
+ progs/demos/Makefile   |    2 +-
+ progs/glsl/Makefile    |    2 +-
+ progs/redbook/Makefile |    2 +-
+ progs/samples/Makefile |    2 +-
+ progs/xdemos/Makefile  |    2 +-
+ 5 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/progs/demos/Makefile b/progs/demos/Makefile
+index 5b1d2a0..121b862 100644
+--- a/progs/demos/Makefile
++++ b/progs/demos/Makefile
+@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
+ 	$(APP_LIB_DEPS)
+ 
+ PROGS = \
+diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
+index 3b5a595..836c4ac 100644
+--- a/progs/glsl/Makefile
++++ b/progs/glsl/Makefile
+@@ -10,7 +10,7 @@ LIB_DEP = \
+ 	$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ 	$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
+ 	-l$(GL_LIB) $(APP_LIB_DEPS)
+ 
+ # using : to avoid APP_CC pointing to CC loop
+diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
+index b41e488..95ed746 100644
+--- a/progs/redbook/Makefile
++++ b/progs/redbook/Makefile
+@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
+ 
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = aaindex \
+ 	aapoly \
+diff --git a/progs/samples/Makefile b/progs/samples/Makefile
+index 64fa47a..9f72c8b 100644
+--- a/progs/samples/Makefile
++++ b/progs/samples/Makefile
+@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
+ 
+ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+ 
+ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
+ 	font line logo nurb olympic overlay point prim rgbtoppm quad select \
+diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
+index f866a32..c0f4e06 100644
+--- a/progs/xdemos/Makefile
++++ b/progs/xdemos/Makefile
+@@ -11,7 +11,7 @@
+ # Add X11 and pthread libs to satisfy GNU gold.
+ APP_LIB_DEPS += -lX11 -lpthread
+ 
+-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
++LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
+
+ 
+ PROGS = \
+ 	corender \
+-- 
+1.7.0
+
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 8/9] htcdream: don't set PREFERRED_PROVIDER_virtual/libgl to mesa-dri
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (6 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 7/9] mesa: move common definitions to include file, change SRC_URI to freedesktop for releases newer than 7.5 Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-25 12:19 ` [PATCH 9/9] mesa: switch to new staging Martin Jansa
  2010-06-25 12:36 ` recipes/mesa cleanup Graeme Gregory
  9 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

* there was --disable-egl in mesa-dri recipes (there are mesa recipes for this)

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 conf/machine/htcdream.conf |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/conf/machine/htcdream.conf b/conf/machine/htcdream.conf
index 89604d5..a10edb8 100644
--- a/conf/machine/htcdream.conf
+++ b/conf/machine/htcdream.conf
@@ -19,5 +19,3 @@ MACHINE_EXTRA_RRECOMMENDS = "\
 "
 
 PREFERRED_PROVIDER_virtual/kernel = "linux-leviathan"
-
-PREFERRED_PROVIDER_virtual/libgl_shr = "mesa-dri"
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 9/9] mesa: switch to new staging
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (7 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 8/9] htcdream: don't set PREFERRED_PROVIDER_virtual/libgl to mesa-dri Martin Jansa
@ 2010-06-25 12:19 ` Martin Jansa
  2010-06-25 12:36 ` recipes/mesa cleanup Graeme Gregory
  9 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-25 12:19 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 recipes/mesa/mesa-common.inc |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/recipes/mesa/mesa-common.inc b/recipes/mesa/mesa-common.inc
index 51f7873..dd66410 100644
--- a/recipes/mesa/mesa-common.inc
+++ b/recipes/mesa/mesa-common.inc
@@ -4,7 +4,7 @@ DESCRIPTION = "An open source implementation of the OpenGL spec"
 HOMEPAGE = "http://mesa3d.org"
 LICENSE = "MIT"
 
-INC_PR = "r8"
+INC_PR = "r9"
 PE = "2"
 
 PROTO_DEPS = "xf86driproto glproto"
@@ -47,15 +47,12 @@ FILES_libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/osmesa.h"
 FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
 FILES_libegl-dbg += "${libdir}/egl/.debug/*"
 
-do_stage() {
-        autotools_stage_all
-		install -d ${STAGING_INCDIR}/GL/	
-		cp -pPr ${S}/include/GL/internal* ${STAGING_INCDIR}/GL/
-}
-
+NATIVE_INSTALL_WORKS = "1"
 do_install_append () {
     install -d ${D}/${bindir}
     for i in glxdemo glxgears glxheads glxinfo; do 
         install -m 0755 ${S}/progs/xdemos/${i} ${D}/${bindir}
     done
+    install -d ${D}/${includedir}/GL
+    cp -pPr ${S}/include/GL/internal* ${D}/${includedir}/GL
 }
-- 
1.7.0.2




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: recipes/mesa cleanup
  2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
                   ` (8 preceding siblings ...)
  2010-06-25 12:19 ` [PATCH 9/9] mesa: switch to new staging Martin Jansa
@ 2010-06-25 12:36 ` Graeme Gregory
  2010-06-25 12:50   ` Henning Heinold
  9 siblings, 1 reply; 20+ messages in thread
From: Graeme Gregory @ 2010-06-25 12:36 UTC (permalink / raw)
  To: openembedded-devel

On Fri, 25 Jun 2010 14:19:34 +0200
Martin Jansa <martin.jansa@gmail.com> wrote:

> Hi,
> 
> i know the rules about removing old versions, but in this dir there
> were versions really old and I'm pretty sure they cant be even built
> with current OE (I tried in few cases and then refused to spend whole
> day just to confirm that some 6.0 version still builds after
> converting to new staging and cleanups..).
> 
> Please review/test.
> 
> FYI: all those patches are often rebased on top of oe.dev also here 
> http://gitorious.org/~jama/angstrom/jama-shr-experimental 
> if cherry-picking is more effective way for you to test
> 

Looks good to me, there is no problem with removing broken recipes.
Whole series

Acked-by: Graeme Gregory <dp@xora.org.uk>

G



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: recipes/mesa cleanup
  2010-06-25 12:36 ` recipes/mesa cleanup Graeme Gregory
@ 2010-06-25 12:50   ` Henning Heinold
  0 siblings, 0 replies; 20+ messages in thread
From: Henning Heinold @ 2010-06-25 12:50 UTC (permalink / raw)
  To: openembedded-devel

> On Fri, 25 Jun 2010 14:19:34 +0200
> Martin Jansa <martin.jansa@gmail.com> wrote:
> 
> > Hi,
> > 
> > i know the rules about removing old versions, but in this dir there
> > were versions really old and I'm pretty sure they cant be even built
> > with current OE (I tried in few cases and then refused to spend whole
> > day just to confirm that some 6.0 version still builds after
> > converting to new staging and cleanups..).
> > 
> > Please review/test.
> > 


Acked-by: Henning Heinold <heinold@inf.fu-berlin.de>

Bye Henning



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file
  2010-06-25 12:19 ` [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file Martin Jansa
@ 2010-06-26  8:32   ` Frans Meulenbroeks
  2010-06-28 10:28     ` Marcin Juszkiewicz
  0 siblings, 1 reply; 20+ messages in thread
From: Frans Meulenbroeks @ 2010-06-26  8:32 UTC (permalink / raw)
  To: openembedded-devel

2010/6/25 Martin Jansa <martin.jansa@gmail.com>:
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  recipes/mesa/mesa-6.0.1/Make-config.patch |   26 ---------------
>  recipes/mesa/mesa-6.0.1/mklib.patch       |   22 -------------
>  recipes/mesa/mesa_6.0.1.bb                |   29 -----------------
>  recipes/mesa/mesa_6.4.1+cvs20060101.bb    |   48 -----------------------------
>  4 files changed, 0 insertions(+), 125 deletions(-)
>  delete mode 100644 recipes/mesa/mesa-6.0.1/Make-config.patch
>  delete mode 100644 recipes/mesa/mesa-6.0.1/mklib.patch
>  delete mode 100644 recipes/mesa/mesa_6.0.1.bb
>  delete mode 100644 recipes/mesa/mesa_6.4.1+cvs20060101.bb
>
> diff --git a/recipes/mesa/mesa-6.0.1/Make-config.patch b/recipes/mesa/mesa-6.0.1/Make-config.patch
> deleted file mode 100644
> index cfe8890..0000000
> --- a/recipes/mesa/mesa-6.0.1/Make-config.patch
> +++ /dev/null
> @@ -1,26 +0,0 @@
> ---- mesa/Make-config.orig      2004-06-25 13:09:44.000000000 +0100
> -+++ mesa/Make-config   2004-06-25 14:18:27.000000000 +0100
> -@@ -643,16 +643,16 @@
> -       "GLUT_LIB = libglut.so" \
> -       "GLW_LIB = libGLw.so" \
> -       "OSMESA_LIB = libOSMesa.so" \
> --      "CC = gcc" \
> --      "CXX = g++" \
> --      "CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include" \
> --      "CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE" \
> -+      "CC = $(CC)" \
> -+      "CXX = $(CXX)" \
> -+      "CFLAGS = -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS $(CFLAGS)" \
> -+      "CXXFLAGS = -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE $(CXXFLAGS)" \
> -       "GLUT_CFLAGS = -fexceptions" \
> --      "GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread" \
> -+      "GL_LIB_DEPS = $(LDFLAGS) -lX11 -lXext -lm -lpthread" \
> -       "OSMESA_LIB_DEPS = -L$(TOP)/lib -lGL" \
> -       "GLU_LIB_DEPS = -L$(TOP)/lib -lGL -lm" \
> --      "GLUT_LIB_DEPS = -L$(TOP)/lib -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm" \
> --      "GLW_LIB_DEPS = -L$(TOP)/lib -lGL -L/usr/X11R6/lib -lXt -lX11" \
> -+      "GLUT_LIB_DEPS = $(LDFLAGS) -L$(TOP)/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm" \
> -+      "GLW_LIB_DEPS = $(LDFLAGS) -L$(TOP)/lib -lGL -lXt -lX11" \
> -       "APP_LIB_DEPS = -lglut -lGLU -lGL -lm"
> -
> - linux-static:
> diff --git a/recipes/mesa/mesa-6.0.1/mklib.patch b/recipes/mesa/mesa-6.0.1/mklib.patch
> deleted file mode 100644
> index 7dc1ec7..0000000
> --- a/recipes/mesa/mesa-6.0.1/mklib.patch
> +++ /dev/null
> @@ -1,22 +0,0 @@
> ---- mesa/bin/mklib.old 2004-06-25 14:08:41.000000000 +0100
> -+++ mesa/bin/mklib     2004-06-25 14:23:09.000000000 +0100
> -@@ -64,6 +64,7 @@
> -       '-install')   shift 1; INSTALLDIR=$1;;
> -       '-arch')      shift 1; ARCH=$1;;
> -       '-archopt')   shift 1; ARCHOPT=$1;;
> -+      -Wl*)         DEPS="$DEPS $1";;
> -       -*)           echo "mklib: Unknown option: " $1 ; exit 1;;
> -       *) break
> -     esac
> -@@ -137,9 +138,9 @@
> -             echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
> -
> -             if [ $CPLUSPLUS = 1 ] ; then
> --                LINK="g++"
> -+                LINK="$CXX"
> -             else
> --                LINK="gcc"
> -+                LINK="$CC"
> -             fi
> -
> -             # rm any old libs
> diff --git a/recipes/mesa/mesa_6.0.1.bb b/recipes/mesa/mesa_6.0.1.bb
> deleted file mode 100644
> index 3b37b8f..0000000
> --- a/recipes/mesa/mesa_6.0.1.bb
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -SECTION = "unknown"
> -SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2 \
> -       file://Make-config.patch \
> -       file://mklib.patch"
> -S = "${WORKDIR}/Mesa-${PV}"
> -PE = "2"
> -LICENSE = "LGPL"
> -# gcc-3.4 blows up in gtktext with -frename-registers on arm-linux
> -CXXFLAGS := "${@'${CXXFLAGS}'.replace('-frename-registers', '')}"
> -DEPENDS = "makedepend-native"
> -
> -do_compile() {
> -       oe_runmake linux CC="${CC}" CXX="${CXX}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LD="${LD}" LDFLAGS="${LDFLAGS}"
> -}
> -
> -do_install() {
> -       install -d ${D}${libdir}
> -       cp -pP lib/* ${D}${libdir}/
> -       install -d ${D}${includedir}
> -       cp -R include/GL ${D}${includedir}/
> -}
> -
> -do_stage() {
> -        cp -pP lib/* ${STAGING_LIBDIR}/
> -        cp -R include/GL ${STAGING_INCDIR}/
> -}
> -
> -SRC_URI[md5sum] = "b7f14088c5c2f14490d2739a91102112"
> -SRC_URI[sha256sum] = "2de039f7abe10569b681ea1d9e21fb65fd0081c8f4db40fb62b332acb11679fb"
> diff --git a/recipes/mesa/mesa_6.4.1+cvs20060101.bb b/recipes/mesa/mesa_6.4.1+cvs20060101.bb
> deleted file mode 100644
> index 9fceca1..0000000
> --- a/recipes/mesa/mesa_6.4.1+cvs20060101.bb
> +++ /dev/null
> @@ -1,48 +0,0 @@
> -SECTION = "unknown"
> -
> -SRCDATE = "20060101"
> -PV = "6.4.1+cvs${SRCDATE}"
> -PE = "2"
> -PR = "r1"
> -
> -SRC_URI = "${FREEDESKTOP_CVS}/mesa;module=Mesa;method=pserver;date=${SRCDATE} \
> -       file://mklib-rpath-link.patch"
> -S = "${WORKDIR}/Mesa"
> -
> -LICENSE = "LGPL"
> -
> -RDEPENDS_${PN} = "expat"
> -DEPENDS = "makedepend-native xf86vidmodeproto glproto virtual/libx11 libxext libxxf86vm libxi libxmu libice"
> -
> -# gcc-3.4 blows up in gtktext with -frename-registers on arm-linux
> -CXXFLAGS := "${@'${CXXFLAGS}'.replace('-frename-registers', '')}"
> -
> -do_configure() {
> -       cd configs
> -
> -       ln -sf linux current
> -       sed -e "s%CC *= *.*%CC = ${CC}%" -i current
> -       sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
> -       sed -e "s%LD *= *.*%LD = ${LD}%" -i current
> -       sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
> -       sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
> -       sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
> -       sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
> -       echo "SRC_DIRS = mesa glu glut/glx" >> current
> -}
> -
> -do_compile() {
> -       oe_runmake default
> -}
> -
> -do_install() {
> -       install -d ${D}${libdir}
> -       cp -pP lib/* ${D}${libdir}/
> -       install -d ${D}${includedir}
> -       cp -R include/GL ${D}${includedir}/
> -}
> -
> -do_stage() {
> -        cp -pP lib/* ${STAGING_LIBDIR}/
> -        cp -R include/GL ${STAGING_INCDIR}/
> -}
> --
> 1.7.0.2
>

Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in  any distro/include config
  2010-06-25 12:19 ` [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in any distro/include config Martin Jansa
@ 2010-06-26  8:33   ` Frans Meulenbroeks
  2010-06-26 18:56     ` Michael Smith
  0 siblings, 1 reply; 20+ messages in thread
From: Frans Meulenbroeks @ 2010-06-26  8:33 UTC (permalink / raw)
  To: openembedded-devel

2010/6/25 Martin Jansa <martin.jansa@gmail.com>:
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  recipes/mesa/mesa-dri_7.4.bb  |   27 ---------------------------
>  recipes/mesa/mesa-xlib_7.4.bb |   24 ------------------------
>  recipes/mesa/mesa_7.4.bb      |    2 --
>  3 files changed, 0 insertions(+), 53 deletions(-)
>  delete mode 100644 recipes/mesa/mesa-dri_7.4.bb
>  delete mode 100644 recipes/mesa/mesa-xlib_7.4.bb
>  delete mode 100644 recipes/mesa/mesa_7.4.bb
>
> diff --git a/recipes/mesa/mesa-dri_7.4.bb b/recipes/mesa/mesa-dri_7.4.bb
> deleted file mode 100644
> index a78c03f..0000000
> --- a/recipes/mesa/mesa-dri_7.4.bb
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -include mesa-common.inc
> -
> -PROTO_DEPS = "xf86driproto glproto dri2proto expat"
> -LIB_DEPS = "libdrm virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
> -
> -DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
> -
> -PR = "${INC_PR}.0"
> -
> -# most of our targets do not have DRI so will use mesa-xlib
> -DEFAULT_PREFERENCE = "-1"
> -
> -# ASUS EeePC 901 has DRI support so use mesa-dri by default
> -DEFAULT_PREFERENCE_eee901 = "1"
> -
> -PACKAGES =+ "${PN}-xprogs"
> -
> -FILES_${PN} += "${libdir}/dri/*.so"
> -FILES_${PN}-dbg += "${libdir}/dri/.debug/*"
> -FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
> -
> -EXTRA_OECONF += "--with-driver=dri --with-dri-drivers=swrast,${MACHINE_DRI_MODULES}"
> -
> -SRC_URI[archive.md5sum] = "7ecddb341a2691e0dfdb02f697109834"
> -SRC_URI[archive.sha256sum] = "6e945389add4e5b41f2c403ced13c343767565f2eacde4b16de2d0f9f8a6aac4"
> -SRC_URI[demos.md5sum] = "02816f10f30b1dc5e069e0f68c177c98"
> -SRC_URI[demos.sha256sum] = "c3de74d62f925e32030adb3d0edcfb3c7a4129fc92c48181a389eeed8f14b897"
> diff --git a/recipes/mesa/mesa-xlib_7.4.bb b/recipes/mesa/mesa-xlib_7.4.bb
> deleted file mode 100644
> index 68e7218..0000000
> --- a/recipes/mesa/mesa-xlib_7.4.bb
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -include mesa-common.inc
> -
> -PROTO_DEPS = "xf86driproto glproto"
> -LIB_DEPS = "virtual/libx11 libxext libxxf86vm libxdamage libxfixes"
> -
> -DEPENDS = "${PROTO_DEPS}  ${LIB_DEPS}"
> -
> -PR = "${INC_PR}.0"
> -
> -EXTRA_OECONF += "--with-driver=xlib"
> -
> -PACKAGES =+ "${PN}-xprogs"
> -
> -FILES_${PN}-xprogs = "${bindir}/glxdemo ${bindir}/glxgears ${bindir}/glxheads ${bindir}/glxinfo"
> -
> -do_install_append () {
> -    install -d ${D}/${bindir}
> -    install -m 0755 ${S}/progs/xdemos/{glxdemo,glxgears,glxheads,glxinfo} ${D}/${bindir}
> -}
> -
> -SRC_URI[archive.md5sum] = "7ecddb341a2691e0dfdb02f697109834"
> -SRC_URI[archive.sha256sum] = "6e945389add4e5b41f2c403ced13c343767565f2eacde4b16de2d0f9f8a6aac4"
> -SRC_URI[demos.md5sum] = "02816f10f30b1dc5e069e0f68c177c98"
> -SRC_URI[demos.sha256sum] = "c3de74d62f925e32030adb3d0edcfb3c7a4129fc92c48181a389eeed8f14b897"
> diff --git a/recipes/mesa/mesa_7.4.bb b/recipes/mesa/mesa_7.4.bb
> deleted file mode 100644
> index 43cde67..0000000
> --- a/recipes/mesa/mesa_7.4.bb
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -# This is a dummy package so OE can use the poky mesa files
> -require mesa-dri_${PV}.bb
> --
> 1.7.0.2
>

Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/9] mesa-dri: remove old 7.0.3 and 6.5.2 relase using mesa-common-old.inc
  2010-06-25 12:19 ` [PATCH 4/9] mesa-dri: remove old 7.0.3 and 6.5.2 relase using mesa-common-old.inc Martin Jansa
@ 2010-06-26  8:33   ` Frans Meulenbroeks
  0 siblings, 0 replies; 20+ messages in thread
From: Frans Meulenbroeks @ 2010-06-26  8:33 UTC (permalink / raw)
  To: openembedded-devel

2010/6/25 Martin Jansa <martin.jansa@gmail.com>:
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  recipes/mesa/files/fix-progs-makefile.patch |   81 ---------------------------
>  recipes/mesa/files/mklib-cross.patch        |   14 -----
>  recipes/mesa/files/mklib-rpath-link.patch   |   20 -------
>  recipes/mesa/mesa-common-old.inc            |   15 -----
>  recipes/mesa/mesa-dri_6.5.2.bb              |   44 --------------
>  recipes/mesa/mesa-dri_7.0.3.bb              |   45 ---------------
>  6 files changed, 0 insertions(+), 219 deletions(-)
>  delete mode 100644 recipes/mesa/files/fix-progs-makefile.patch
>  delete mode 100644 recipes/mesa/files/mklib-cross.patch
>  delete mode 100644 recipes/mesa/files/mklib-rpath-link.patch
>  delete mode 100644 recipes/mesa/mesa-common-old.inc
>  delete mode 100644 recipes/mesa/mesa-dri_6.5.2.bb
>  delete mode 100644 recipes/mesa/mesa-dri_7.0.3.bb
>
> diff --git a/recipes/mesa/files/fix-progs-makefile.patch b/recipes/mesa/files/fix-progs-makefile.patch
> deleted file mode 100644
> index f0a8293..0000000
> --- a/recipes/mesa/files/fix-progs-makefile.patch
> +++ /dev/null
> @@ -1,81 +0,0 @@
> -From e03daf13a562414f07230c17998edd39564b5f1b Mon Sep 17 00:00:00 2001
> -From: Martin Jansa <Martin.Jansa@gmail.com>
> -Date: Thu, 4 Mar 2010 14:16:27 +0100
> -Subject: [PATCH] fix libs
> -
> ----
> - progs/demos/Makefile   |    2 +-
> - progs/glsl/Makefile    |    2 +-
> - progs/redbook/Makefile |    2 +-
> - progs/samples/Makefile |    2 +-
> - progs/xdemos/Makefile  |    2 +-
> - 5 files changed, 5 insertions(+), 5 deletions(-)
> -
> -diff --git a/progs/demos/Makefile b/progs/demos/Makefile
> -index 5b1d2a0..121b862 100644
> ---- a/progs/demos/Makefile
> -+++ b/progs/demos/Makefile
> -@@ -8,7 +8,7 @@ INCDIR = $(TOP)/include
> - LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
> -       $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
> -
> --LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
> -+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ \
> -       $(APP_LIB_DEPS)
> -
> - PROGS = \
> -diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
> -index 3b5a595..836c4ac 100644
> ---- a/progs/glsl/Makefile
> -+++ b/progs/glsl/Makefile
> -@@ -10,7 +10,7 @@ LIB_DEP = \
> -       $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
> -       $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
> -
> --LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
> -+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -lstdc++ \
> -       -l$(GL_LIB) $(APP_LIB_DEPS)
> -
> - # using : to avoid APP_CC pointing to CC loop
> -diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile
> -index b41e488..95ed746 100644
> ---- a/progs/redbook/Makefile
> -+++ b/progs/redbook/Makefile
> -@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
> -
> - LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
> -
> --LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
> -+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
> -
> - PROGS = aaindex \
> -       aapoly \
> -diff --git a/progs/samples/Makefile b/progs/samples/Makefile
> -index 64fa47a..9f72c8b 100644
> ---- a/progs/samples/Makefile
> -+++ b/progs/samples/Makefile
> -@@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
> -
> - LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
> -
> --LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
> -+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
> -
> - PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
> -       font line logo nurb olympic overlay point prim rgbtoppm quad select \
> -diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
> -index f866a32..c0f4e06 100644
> ---- a/progs/xdemos/Makefile
> -+++ b/progs/xdemos/Makefile
> -@@ -11,7 +11,7 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
> - # Add X11 and pthread libs to satisfy GNU gold.
> - APP_LIB_DEPS += -lX11 -lpthread
> -
> --LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
> -+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lstdc++ $(APP_LIB_DEPS)
> -
> - PROGS = \
> -       corender \
> ---
> -1.7.0
> -
> diff --git a/recipes/mesa/files/mklib-cross.patch b/recipes/mesa/files/mklib-cross.patch
> deleted file mode 100644
> index fbe86e3..0000000
> --- a/recipes/mesa/files/mklib-cross.patch
> +++ /dev/null
> @@ -1,14 +0,0 @@
> ---- s/bin/mklib~       2008-02-19 15:30:18.000000000 +0000
> -+++ s/bin/mklib        2008-07-27 11:15:25.000000000 +0100
> -@@ -204,9 +204,9 @@
> -       if [ "x$LINK" = "x" ] ; then
> -           # -linker was not specified so set default link command now
> -             if [ $CPLUSPLUS = 1 ] ; then
> --                LINK=g++
> -+                LINK=$CXX
> -             else
> --                LINK=gcc
> -+                LINK=$CC
> -             fi
> -       fi
> -
> diff --git a/recipes/mesa/files/mklib-rpath-link.patch b/recipes/mesa/files/mklib-rpath-link.patch
> deleted file mode 100644
> index 07361f5..0000000
> --- a/recipes/mesa/files/mklib-rpath-link.patch
> +++ /dev/null
> @@ -1,20 +0,0 @@
> ---- Mesa/bin/mklib.orig        2006-06-04 20:56:22.000000000 -0600
> -+++ Mesa/bin/mklib     2006-06-04 20:57:04.000000000 -0600
> -@@ -98,6 +98,9 @@
> -       -L*)
> -           DEPS="$DEPS $1"
> -           ;;
> -+      -Wl*)
> -+          DEPS="$DEPS $1"
> -+          ;;
> -       '-cplusplus')
> -           CPLUSPLUS=1
> -           ;;
> ---- Mesa/configs/default.orig  2006-06-04 21:01:47.000000000 -0600
> -+++ Mesa/configs/default       2006-06-04 21:01:16.000000000 -0600
> -@@ -71,4 +71,4 @@
> - GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
> - GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
> - GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
> --APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
> -+APP_LIB_DEPS = -L$(LIB_DIR) $(EXTRA_LIB_PATH) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
> diff --git a/recipes/mesa/mesa-common-old.inc b/recipes/mesa/mesa-common-old.inc
> deleted file mode 100644
> index 01f0adc..0000000
> --- a/recipes/mesa/mesa-common-old.inc
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -SECTION = "x11"
> -PE = "2"
> -
> -SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2 \
> -       file://mklib-rpath-link.patch"
> -
> -S = "${WORKDIR}/Mesa-${PV}"
> -
> -PROVIDES = "virtual/libgl"
> -
> -LICENSE = "LGPL"
> -
> -INC_PR = "r3"
> -
> -DEPENDS = "makedepend-native xf86vidmodeproto glproto virtual/libx11 libxext libxxf86vm libxi libxmu libice"
> diff --git a/recipes/mesa/mesa-dri_6.5.2.bb b/recipes/mesa/mesa-dri_6.5.2.bb
> deleted file mode 100644
> index d8f9506..0000000
> --- a/recipes/mesa/mesa-dri_6.5.2.bb
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -include mesa-common-old.inc
> -
> -SRC_URI += " file://mklib-cross.patch"
> -
> -FILESPATHPKG =. "mesa-${PV}:"
> -
> -PACKAGES_DYNAMIC = "mesa-dri-driver-*"
> -
> -PR = "${INC_PR}.1"
> -
> -DEPENDS += "libdrm"
> -# DRI is useless without the kernel drivers
> -RRECOMMENDS_${PN} += " kernel-module-drm kernel-module-radeon "
> -
> -do_configure() {
> -       cd configs
> -
> -       ln -sf linux-dri current
> -       sed -e "s%CC *= *.*%CC = ${CC}%" -i current
> -       sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
> -       sed -e "s%LD *= *.*%LD = ${LD}%" -i current
> -       sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
> -       sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
> -       sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
> -       sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
> -       echo "SRC_DIRS = mesa" >> current
> -       echo "DRI_DRIVER_INSTALL_DIR = ${D}${libdir}/dri" >> current
> -}
> -
> -do_install() {
> -       oe_runmake -C src/mesa/drivers/dri install
> -}
> -
> -FILES_${PN}-dbg += "${libdir}/dri/.debug"
> -
> -python populate_packages_prepend () {
> -        import re, os.path
> -
> -        do_split_packages(d, root=bb.data.expand('${libdir}/dri', d), file_regex='(.*)_dri\.so', output_pattern='mesa-dri-driver-%s', description='%s DRI driver', extra_depends='')
> -}
> -
> -
> -SRC_URI[md5sum] = "e4d894181f1859651658b3704633e10d"
> -SRC_URI[sha256sum] = "137f50a30461d51eb9af5aac737bc788d536354cf47b26129b97bde6e41fb85f"
> diff --git a/recipes/mesa/mesa-dri_7.0.3.bb b/recipes/mesa/mesa-dri_7.0.3.bb
> deleted file mode 100644
> index dcf6fd3..0000000
> --- a/recipes/mesa/mesa-dri_7.0.3.bb
> +++ /dev/null
> @@ -1,45 +0,0 @@
> -include mesa-common-old.inc
> -
> -# suppress mklib-rpath-link patch from mesa-common
> -SRC_URI = "${SOURCEFORGE_MIRROR}/mesa3d/MesaLib-${PV}.tar.bz2 file://mklib-cross.patch"
> -
> -FILESPATHPKG =. "mesa-${PV}:"
> -
> -PACKAGES_DYNAMIC = "mesa-dri-driver-*"
> -
> -PR = "${INC_PR}.1"
> -
> -DEPENDS += "libdrm"
> -# DRI is useless without the kernel drivers
> -RRECOMMENDS_${PN} += " kernel-module-drm kernel-module-radeon "
> -
> -do_configure() {
> -       cd configs
> -
> -       ln -sf linux-dri current
> -       sed -e "s%CC *= *.*%CC = ${CC}%" -i current
> -       sed -e "s%CXX *= *.*%CXX = ${CXX}%" -i current
> -       sed -e "s%LD *= *.*%LD = ${LD}%" -i current
> -       sed -e "s%OPT_FLAGS *= *.*%OPT_FLAGS = ${TARGET_CFLAGS}%" -i current
> -       sed -e "s%X11_INCLUDES *= *.*%X11_INCLUDES = -I${STAGING_INCDIR}/X11%" -i current
> -       sed -e "s%EXTRA_LIB_PATH *= *.*%EXTRA_LIB_PATH = ${LDFLAGS}%" -i current
> -       sed -i s:\$\(CC\):gcc:g  ../src/mesa/x86/Makefile
> -       echo "SRC_DIRS = mesa" >> current
> -       echo "DRI_DRIVER_INSTALL_DIR = ${D}${libdir}/dri" >> current
> -}
> -
> -do_install() {
> -       oe_runmake -C src/mesa/drivers/dri install
> -}
> -
> -FILES_${PN}-dbg += "${libdir}/dri/.debug"
> -
> -python populate_packages_prepend () {
> -        import re, os.path
> -
> -        do_split_packages(d, root=bb.data.expand('${libdir}/dri', d), file_regex='(.*)_dri\.so', output_pattern='mesa-dri-driver-%s', description='%s DRI driver', extra_depends='')
> -}
> -
> -
> -SRC_URI[md5sum] = "e6e6379d7793af40a6bc3ce1bace572e"
> -SRC_URI[sha256sum] = "ebdf3448eac8abb56bbfc0b7c015efce8e5d88f10ee3123dcc62c1ff47b62d22"
> --
> 1.7.0.2
>

Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in  any distro/include config
  2010-06-26  8:33   ` Frans Meulenbroeks
@ 2010-06-26 18:56     ` Michael Smith
  2010-06-26 19:23       ` Martin Jansa
  0 siblings, 1 reply; 20+ messages in thread
From: Michael Smith @ 2010-06-26 18:56 UTC (permalink / raw)
  To: openembedded-devel

> From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
> To: openembedded-devel@lists.openembedded.org
> Sent: 26.6.'10,  4:33
>
> 2010/6/25 Martin Jansa <martin.jansa@gmail.com>:
>> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>

Nack here, I'm using 7.4.

Thanks,
Mike 



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in  any distro/include config
  2010-06-26 18:56     ` Michael Smith
@ 2010-06-26 19:23       ` Martin Jansa
  0 siblings, 0 replies; 20+ messages in thread
From: Martin Jansa @ 2010-06-26 19:23 UTC (permalink / raw)
  To: openembedded-devel

On Sat, Jun 26, 2010 at 02:56:31PM -0400, Michael Smith wrote:
> >From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
> >To: openembedded-devel@lists.openembedded.org
> >Sent: 26.6.'10,  4:33
> >
> >2010/6/25 Martin Jansa <martin.jansa@gmail.com>:
> >>Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> 
> Nack here, I'm using 7.4.

7.4 also converted and readded, please test (I tried only if all patches
apllies as before).

Regards,
-- 
Jansa 'JaMa' Martin     jabber: Martin.Jansa@gmail.com



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file
  2010-06-26  8:32   ` Frans Meulenbroeks
@ 2010-06-28 10:28     ` Marcin Juszkiewicz
  2010-06-28 11:41       ` Koen Kooi
  0 siblings, 1 reply; 20+ messages in thread
From: Marcin Juszkiewicz @ 2010-06-28 10:28 UTC (permalink / raw)
  To: openembedded-devel

Dnia sobota, 26 czerwca 2010 o 10:32:28 Frans Meulenbroeks napisał(a):
> 2010/6/25 Martin Jansa <martin.jansa@gmail.com>:

[ very long diff cut ]

> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>

Can people cut mail contents when reply? Whole mail needs to be scrolled just 
to see "Acked"...

And it is not only Frans :(

Regards, 
-- 
JID:      hrw@jabber.org
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz





^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file
  2010-06-28 10:28     ` Marcin Juszkiewicz
@ 2010-06-28 11:41       ` Koen Kooi
  2010-06-28 12:07         ` Dr. Michael Lauer
  0 siblings, 1 reply; 20+ messages in thread
From: Koen Kooi @ 2010-06-28 11:41 UTC (permalink / raw)
  To: openembedded-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

And if cutting is too hard, there's always the option to top post :)

On 28-06-10 12:28, Marcin Juszkiewicz wrote:
> Dnia sobota, 26 czerwca 2010 o 10:32:28 Frans Meulenbroeks napisał(a):
>> 2010/6/25 Martin Jansa <martin.jansa@gmail.com>:
> 
> [ very long diff cut ]
> 
>> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
> 
> Can people cut mail contents when reply? Whole mail needs to be scrolled just 
> to see "Acked"...
> 
> And it is not only Frans :(
> 
> Regards, 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFMKIpZMkyGM64RGpERAngkAKCzTkI2ydJow1QqdE3wTVmZaSJ4aQCeMzBC
eyls6sQw/ffntMdR8hb0Tl0=
=jbeZ
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file
  2010-06-28 11:41       ` Koen Kooi
@ 2010-06-28 12:07         ` Dr. Michael Lauer
  0 siblings, 0 replies; 20+ messages in thread
From: Dr. Michael Lauer @ 2010-06-28 12:07 UTC (permalink / raw)
  To: openembedded-devel

Am 28.06.2010 um 13:41 schrieb Koen Kooi:

> And if cutting is too hard, there's always the option to top post :)

Agreed. In that case I think top-posting is perfectly acceptable.

Cheers,

:M:




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-06-28 12:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-25 12:19 recipes/mesa cleanup Martin Jansa
2010-06-25 12:19 ` [PATCH 1/9] mesa: remove old 6.0 and 6.4 recipes which are not using any include file Martin Jansa
2010-06-26  8:32   ` Frans Meulenbroeks
2010-06-28 10:28     ` Marcin Juszkiewicz
2010-06-28 11:41       ` Koen Kooi
2010-06-28 12:07         ` Dr. Michael Lauer
2010-06-25 12:19 ` [PATCH 2/9] preferred-om-2008-versions: remove pinned version of mesa/mesa-dri Martin Jansa
2010-06-25 12:19 ` [PATCH 3/9] mesa: remove old releases 6.5.2, 7.0.2 using mesa-mesa.inc Martin Jansa
2010-06-25 12:19 ` [PATCH 4/9] mesa-dri: remove old 7.0.3 and 6.5.2 relase using mesa-common-old.inc Martin Jansa
2010-06-26  8:33   ` Frans Meulenbroeks
2010-06-25 12:19 ` [PATCH 5/9] mesa: remove 7.4 release, which is not pinned in any distro/include config Martin Jansa
2010-06-26  8:33   ` Frans Meulenbroeks
2010-06-26 18:56     ` Michael Smith
2010-06-26 19:23       ` Martin Jansa
2010-06-25 12:19 ` [PATCH 6/9] mesa: move 7.8 release to latest minor 7.8.2 Martin Jansa
2010-06-25 12:19 ` [PATCH 7/9] mesa: move common definitions to include file, change SRC_URI to freedesktop for releases newer than 7.5 Martin Jansa
2010-06-25 12:19 ` [PATCH 8/9] htcdream: don't set PREFERRED_PROVIDER_virtual/libgl to mesa-dri Martin Jansa
2010-06-25 12:19 ` [PATCH 9/9] mesa: switch to new staging Martin Jansa
2010-06-25 12:36 ` recipes/mesa cleanup Graeme Gregory
2010-06-25 12:50   ` Henning Heinold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.