[pkg-nvidia-devel] r1020 - in /packages/nvclock/trunk/debian: changelog patches/ patches/cvs-2009-06-22.diff patches/series

anbe-guest at users.alioth.debian.org anbe-guest at users.alioth.debian.org
Sat Jun 5 13:27:22 UTC 2010


Author: anbe-guest
Date: Sat Jun  5 13:27:14 2010
New Revision: 1020

URL: http://svn.debian.org/wsvn/pkg-nvidia/?sc=1&rev=1020
Log:
update to upstream CVS as of 2009-06-22

Added:
    packages/nvclock/trunk/debian/patches/
    packages/nvclock/trunk/debian/patches/cvs-2009-06-22.diff
    packages/nvclock/trunk/debian/patches/series
Modified:
    packages/nvclock/trunk/debian/changelog

Modified: packages/nvclock/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvclock/trunk/debian/changelog?rev=1020&op=diff
==============================================================================
--- packages/nvclock/trunk/debian/changelog (original)
+++ packages/nvclock/trunk/debian/changelog Sat Jun  5 13:27:14 2010
@@ -19,6 +19,7 @@
   [ Andreas Beckmann ]
   * Team change: switch Uploaders from Randall to Russ.
   * Switch to source format 3.0 (quilt).
+  * Update to upstream CVS as of 2009-06-22.  (Closes: #463890)
 
  -- Andreas Beckmann <debian at abeckmann.de>  Sat, 05 Jun 2010 13:32:18 +0200
 

Added: packages/nvclock/trunk/debian/patches/cvs-2009-06-22.diff
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvclock/trunk/debian/patches/cvs-2009-06-22.diff?rev=1020&op=file
==============================================================================
--- packages/nvclock/trunk/debian/patches/cvs-2009-06-22.diff (added)
+++ packages/nvclock/trunk/debian/patches/cvs-2009-06-22.diff Sat Jun  5 13:27:14 2010
@@ -1,0 +1,1948 @@
+Description: updates from upstream CVS up to 2009-06-22
+ This patch includes all changes between the 0.8b4 tarball and the upstream
+ CVS repository as of 2009-06-22 (date of last commit).
+Origin: upstream, http://nvclock.cvs.sourceforge.net/viewvc/nvclock/
+Last-Update: 2010-06-05
+
+Index: b/configure
+===================================================================
+--- a/configure	2010-06-05 14:45:33.624537043 +0200
++++ b/configure	2010-06-05 14:46:24.936536570 +0200
+@@ -3726,7 +3726,6 @@
+ 
+ 
+ 
+-CFLAGS=
+ HAVE_GTK2=no
+ HAVE_QT=no
+ HAVE_NVCONTROL=no
+Index: b/Makefile.in
+===================================================================
+--- a/Makefile.in	2010-06-05 14:45:33.624537043 +0200
++++ b/Makefile.in	2010-06-05 14:46:24.936536570 +0200
+@@ -1,10 +1,14 @@
+ INSTALL=@INSTALL@
++DESTDIR =
++prefix=@prefix@
++docdir=@docdir@
++mandir=@mandir@
+ 
+-prefix=$(DESTDIR)@prefix@
+-docdir=${prefix}/share/doc/nvclock
+-mandir=${prefix}/man
+ DOCS= ABOUT AUTHORS ChangeLog FAQ README
+ 
++CFLAGS=@CFLAGS@
++CXXFLAGS=@CXXFLAGS@
++
+ all:
+ 	$(MAKE) -C src all
+ 
+@@ -21,7 +25,7 @@
+ install-docs:
+ 	@documentations='$(DOCS)'; \
+ 	for doc in $$documentations; do \
+-	destdir=$(docdir); \
++	destdir=$(DESTDIR)$(docdir); \
+ 	name=`echo $$doc` \
+ 	dir=$$destdir; \
+ 	mkdir -p $$dir; \
+@@ -30,14 +34,14 @@
+ 	done
+ 
+ install-desktop-shortcut:
+-	mkdir -p $(prefix)/share/applications
+-	mkdir -p $(prefix)/share/icons/hicolor/48x48/apps
+-	cp nvclock.desktop $(prefix)/share/applications
+-	cp nvclock.png $(prefix)/share/icons/hicolor/48x48/apps
++	mkdir -p $(DESTDIR)$(prefix)/share/applications
++	mkdir -p $(DESTDIR)$(prefix)/share/icons/hicolor/48x48/apps
++	cp nvclock.desktop $(DESTDIR)$(prefix)/share/applications
++	cp nvclock.png $(DESTDIR)$(prefix)/share/icons/hicolor/48x48/apps
+ 
+ install-man:
+-	mkdir -p $(mandir)/man1
+-	cp nvclock.1 $(mandir)/man1
++	mkdir -p $(DESTDIR)$(mandir)/man1
++	cp nvclock.1 $(DESTDIR)$(mandir)/man1
+ 
+ uninstall: uninstall-docs uninstall-man uninstall-desktop-shortcut
+ 	$(MAKE) -C src uninstall
+@@ -45,7 +49,7 @@
+ uninstall-docs:
+ 	@documentations='$(DOCS)'; \
+ 	for doc in $$documentations; do \
+-	destdir=$(docdir); \
++	destdir=$(DESTDIR)$(docdir); \
+ 	name=`echo $$doc` \
+ 	dir=$$destdir; \
+ 	rm -f $$dir/$$name; \
+@@ -53,11 +57,12 @@
+ 	done
+ 
+ uninstall-desktop-shortcut:
+-	rm -f $(prefix)/share/applications/nvclock.desktop
+-	echo "removing $$prefix/share/applications/nvclock.desktop" ; \
+-	rm -f $(prefix)/share/icons/hicolor/48x48/apps/nvclock.png
+-	echo "removing $$prefix/share/icons/hicolor/48x48/apps/nvclock.png" ; \
++	rm -f $(DESTDIR)$(prefix)/share/applications/nvclock.desktop
++	echo "removing $$(DESTDIR)$$prefix/share/applications/nvclock.desktop" ; \
++	rm -f $(DESTDIR)$(prefix)/share/icons/hicolor/48x48/apps/nvclock.png
++	echo "removing $$(DESTDIR)$$prefix/share/icons/hicolor/48x48/apps/nvclock.png" ; \
+ 
+ uninstall-man:
+-	rm -f $(mandir)/man1/nvclock.1
+-	echo "removing $$mandir/man1/nvclock.1" ; \
++	rm -f $$(DESTDIR)$(mandir)/man1/nvclock.1
++	echo "removing $$(DESTDIR)$$mandir/man1/nvclock.1" ; \
++
+Index: b/configure.in
+===================================================================
+--- a/configure.in	2010-06-05 14:45:33.628537683 +0200
++++ b/configure.in	2010-06-05 14:46:24.936536570 +0200
+@@ -12,7 +12,6 @@
+ AC_HEADER_STDC
+ 
+ 
+-CFLAGS=
+ HAVE_GTK2=no
+ HAVE_QT=no
+ HAVE_NVCONTROL=no
+Index: b/src/nvclock.c
+===================================================================
+--- a/src/nvclock.c	2010-06-05 14:45:33.628537683 +0200
++++ b/src/nvclock.c	2010-06-05 14:46:24.936536570 +0200
+@@ -117,7 +117,7 @@
+ 
+ char *mask_to_device(int mask)
+ {
+-	char *res;
++	char *res = NULL;
+ 	int i=0;
+ 	if(mask & NV_CRT)
+ 	{
+@@ -942,7 +942,7 @@
+ 
+ 	if(fanspeed_opt && force_opt)
+ 	{
+-		float dutycycle;
++		float dutycycle = 0.0;
+ 
+ 		if(!(nv_card->caps & (GPU_FANSPEED_MONITORING | I2C_FANSPEED_MONITORING)))
+ 		{
+Index: b/src/Makefile.in
+===================================================================
+--- a/src/Makefile.in	2010-06-05 14:45:33.668537657 +0200
++++ b/src/Makefile.in	2010-06-05 14:46:24.936536570 +0200
+@@ -1,5 +1,6 @@
+ CC=@CC@
+ INSTALL=@INSTALL@
++CFLAGS=@CFLAGS@
+ 
+ nvclock_SOURCES=nvclock.c
+ smartdimmer_SOURCES=smartdimmer.c
+@@ -8,9 +9,9 @@
+ libbackend=./backend/libbackend.a
+ libnvcontrol=./nvcontrol/libnvcontrol.a
+ 
+-prefix=$(DESTDIR)@prefix@
+-exec_prefix=$(DESTDIR)@exec_prefix@
+-bindir=$(DESTDIR)@bindir@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++bindir=@bindir@
+ 
+ ifeq ($(HAVE_NVCONTROL), yes)
+     DEPS=$(libbackend) $(libnvcontrol)
+@@ -31,10 +32,10 @@
+ 
+ 
+ nvclock: $(DEPS) $(LIB) nvclock.c
+-	$(CC) -o nvclock $(nvclock_SOURCES) $(INCLUDES) $(LIBS)
++	$(CC) $(CFLAGS) -o nvclock $(nvclock_SOURCES) $(INCLUDES) $(LIBS)
+ 
+ smartdimmer: $(DEPS) $(LIB) smartdimmer.c
+-	$(CC) -o smartdimmer $(smartdimmer_SOURCES) $(INCLUDES) $(LIBS)
++	$(CC) $(CFLAGS) -o smartdimmer $(smartdimmer_SOURCES) $(INCLUDES) $(LIBS)
+ 
+ 
+ clean: clean-recursive clean-app
+@@ -56,7 +57,8 @@
+ 
+ uninstall: uninstall-recursive uninstall-app
+ uninstall-app:
+-	rm -f $(bindir)/smartdimmer
++	rm -f $(DESTDIR)$(bindir)/nvclock
++	rm -f $(DESTDIR)$(bindir)/smartdimmer
+ 
+ 
+ # Walk through the sub directories and do what is requested
+Index: b/src/nvcontrol/libnvcontrol.h
+===================================================================
+--- a/src/nvcontrol/libnvcontrol.h	2010-06-05 14:45:33.668537657 +0200
++++ b/src/nvcontrol/libnvcontrol.h	2010-06-05 14:46:24.940536861 +0200
+@@ -164,7 +164,7 @@
+ #define NVGetReq(name, req) \
+     WORD64ALIGN\
+     if ((dpy->bufptr + SIZEOF(xNV##name##Req)) > dpy->bufmax)\
+-	_XFlush(dpy);\
++	XFlush(dpy);\
+     req = (xNV##name##Req *)(dpy->last_req = dpy->bufptr);\
+     req->reqType = dpyinfo->codes->major_opcode;\
+     req->nvReqType = nv_##name; \
+Index: b/src/nvcontrol/Makefile.in
+===================================================================
+--- a/src/nvcontrol/Makefile.in	2010-06-05 14:45:33.668537657 +0200
++++ b/src/nvcontrol/Makefile.in	2010-06-05 14:46:24.940536861 +0200
+@@ -2,7 +2,8 @@
+ AR=ar
+ RANLIB=@RANLIB@
+ system=@system@
+-CFLAGS=@X11_CFLAGS@ -I../backend
++CFLAGS=@CFLAGS@
++CFLAGS+=@X11_CFLAGS@ -I../backend
+ HAVE_X11=@HAVE_NVCONTROL@
+ OBJECTS=libnvcontrol.o nvcontrol.o
+ 
+@@ -26,4 +27,4 @@
+ 	rm -f Makefile
+ 
+ install:
+-uninstall:
+\ No newline at end of file
++uninstall:
+Index: b/src/nvcontrol/libnvcontrol.c
+===================================================================
+--- a/src/nvcontrol/libnvcontrol.c	2010-06-05 14:45:33.668537657 +0200
++++ b/src/nvcontrol/libnvcontrol.c	2010-06-05 14:46:24.940536861 +0200
+@@ -278,7 +278,7 @@
+ 	SyncHandle();
+     }
+     /* make sure the attribute is indeed set */
+-    _XFlush(dpy);
++    XFlush(dpy);
+ }
+ 
+ #define X_NVSelectNotify 6
+Index: b/src/qt/Makefile.in
+===================================================================
+--- a/src/qt/Makefile.in	2010-06-05 14:45:33.668537657 +0200
++++ b/src/qt/Makefile.in	2010-06-05 14:46:24.940536861 +0200
+@@ -3,28 +3,27 @@
+ MOC=@MOC@
+ 
+ OBJECTS=main.o qt_nvclock.o qt_nvclock.moc.o qt_xfree.o qt_xfree.moc.o
+-CXXFLAGS=@QT_CFLAGS@ -I../backend
++CXXFLAGS=@CXXFLAGS@
++CXXFLAGS+=@QT_CFLAGS@ @X11_CFLAGS@ -I../backend
+ HAVE_NVCONTROL=@HAVE_NVCONTROL@
+ HAVE_QT=@HAVE_QT@
+ libbackend=../backend/libbackend.a
+ 
+-prefix=$(DESTDIR)@prefix@
+-exec_prefix=$(DESTDIR)@exec_prefix@
+-bindir=$(DESTDIR)@bindir@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++bindir=@bindir@
+ 
+ ifeq ($(HAVE_QT), yes)
+     PROGRAM=nvclock_qt
+-    INSTALL_APP=mkdir -p $(bindir); $(INSTALL) -c $(PROGRAM) $(bindir)/$(PROGRAM)
+-    UNINSTALL_APP=rm -f $(bindir)/$(PROGRAM)
++    INSTALL_APP=mkdir -p $(DESTDIR)$(bindir); $(INSTALL) -c $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM)
++    UNINSTALL_APP=rm -f $(DESTDIR)$(bindir)/$(PROGRAM)
+ endif
+ 
+ ifeq ($(HAVE_NVCONTROL), yes)
+     DEPS=$(libbackend) $(libnvcontrol)
+-    INCLUDES=@X11_CFLAGS@ -I./backend -I./nvcontrol -I.. -I../..
+     LIBS=@QT_LIBS@ -L../backend -lbackend -L../nvcontrol -lnvcontrol
+ else
+     DEPS=$(libbackend)
+-    INCLUDES=@X11_CFLAGS@ -I./backend -I.. -I../..
+     LIBS=@QT_LIBS@ -L../backend -lbackend
+ endif
+ 
+@@ -32,7 +31,7 @@
+ all: $(PROGRAM)
+ 
+ nvclock_qt: $(DEPS) qt_nvclock.moc qt_xfree.moc $(OBJECTS)
+-	$(CXX) -o nvclock_qt $(CXXFLAGS) $(OBJECTS) $(LIBS) 
++	$(CXX) $(CXXFLAGS) -o nvclock_qt $(CXXFLAGS) $(OBJECTS) $(LIBS) 
+ 
+ clean:
+ 	rm -f nvclock_qt *.core *.moc *.o
+Index: b/src/gtk/Makefile.in
+===================================================================
+--- a/src/gtk/Makefile.in	2010-06-05 14:45:33.668537657 +0200
++++ b/src/gtk/Makefile.in	2010-06-05 14:46:24.940536861 +0200
+@@ -1,30 +1,29 @@
+ CC=@CC@
+ INSTALL=@INSTALL@
+ 
+-CFLAGS=@GTK_CFLAGS@ -I../backend -I../nvcontrol -I../..
++CFLAGS=@CFLAGS@
++CFLAGS+=@GTK_CFLAGS@ @X11_CFLAGS@ -I../backend -I../nvcontrol -I../..
+ HAVE_GTK2=@HAVE_GTK2@
+ HAVE_NVCONTROL=@HAVE_NVCONTROL@
+ libbackend=../backend/libbackend.a
+ libnvcontrol=../nvcontrol/libnvcontrol.a
+ 
+-prefix=$(DESTDIR)@prefix@
+-exec_prefix=$(DESTDIR)@exec_prefix@
+-bindir=$(DESTDIR)@bindir@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++bindir=@bindir@
+ 
+ ifeq ($(HAVE_GTK2), yes)
+     PROGRAM=nvclock_gtk
+-    INSTALL_APP=mkdir -p $(bindir); $(INSTALL) -c $(PROGRAM) $(bindir)/$(PROGRAM)
+-    UNINSTALL_APP=rm -f $(bindir)/$(PROGRAM)
++    INSTALL_APP=mkdir -p $(DESTDIR)$(bindir); $(INSTALL) -c $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM)
++    UNINSTALL_APP=rm -f $(DESTDIR)$(bindir)/$(PROGRAM)
+ endif
+ 
+ ifeq ($(HAVE_NVCONTROL), yes)
+     DEPS=$(libbackend) $(libnvcontrol)
+-    INCLUDES=@X11_CFLAGS@ -I./backend -I./nvcontrol -I.. -I../..
+     LIBS=@GTK_LIBS@ -L../backend -lbackend -L../nvcontrol -lnvcontrol
+     OBJECTS=banner.o gl.o hw.o main.o settings.o
+ else
+     DEPS=$(libbackend)
+-    INCLUDES=-I./backend -I./nvcontrol -I.. -I../..
+     LIBS=@GTK_LIBS@ -L../backend -lbackend
+     OBJECTS=banner.o hw.o main.o settings.o
+ endif
+@@ -34,7 +33,7 @@
+ all: $(PROGRAM)
+ 
+ nvclock_gtk: $(DEPS) $(OBJECTS)
+-	$(CC) -o nvclock_gtk $(OBJECTS) $(libbackend) $(LIBS)
++	$(CC) $(CFLAGS) -o nvclock_gtk $(OBJECTS) $(libbackend) $(LIBS)
+ 
+ clean:
+ 	rm -f nvclock_gtk *.core *.o *.exe
+Index: b/src/gtk/gl.c
+===================================================================
+--- a/src/gtk/gl.c	2010-06-05 14:45:33.668537657 +0200
++++ b/src/gtk/gl.c	2010-06-05 14:46:24.940536861 +0200
+@@ -146,7 +146,7 @@
+ 	if(initialize && conf->save_opengl_changes)
+ 	{
+ 		NVOptionList *opt = nvcontrol_lookup_option(option);
+-		char *name;
++		char *name = NULL;
+ 
+ 		/* Fsaa/Aniso application control aren't stored in our database,
+ 		/  so if the requested option can't be found check if it is one
+@@ -196,7 +196,7 @@
+ 	if(conf->save_opengl_changes)
+ 	{
+ 		NVOptionList *opt = nvcontrol_lookup_option(option);
+-		char *name;
++		char *name = NULL;
+ 
+ 		/* Fsaa/Aniso application control aren't stored in our database,
+ 		/  so if the requested option can't be found check if it is one
+@@ -395,8 +395,8 @@
+ GtkWidget *nv_opengl_new(Display* dpy, int screen)
+ {
+ 	NVOpengl *opengl = g_object_new(NV_TYPE_OPENGL, NULL);
+-	char *glx_vendor, *glx_version, *glx_direct;
+-	char *gl_vendor, *gl_renderer, *gl_version;
++	char *glx_vendor=NULL, *glx_version=NULL, *glx_direct=NULL;
++	char *gl_vendor=NULL, *gl_renderer=NULL, *gl_version=NULL;
+ 
+ 	Window win;
+ 	Window root;
+@@ -441,7 +441,7 @@
+ 	{
+ 		glx_vendor = (char*)pglXQueryServerString(dpy, screen, GLX_VENDOR);
+ 		glx_version = (char*)pglXQueryServerString(dpy, screen, GLX_VERSION);
+-		glx_direct = (char*)(pglXIsDirect(dpy, ctx) ? "Yes" : "No");
++		glx_direct = (pglXIsDirect(dpy, ctx) ? (char*)"Yes" : (char*)"No");
+ 		gl_vendor = (char*)pglGetString(GL_VENDOR);
+ 		gl_renderer = (char*)pglGetString(GL_RENDERER);
+ 		gl_version = (char*)pglGetString(GL_VERSION);
+Index: b/src/gtk/hw.c
+===================================================================
+--- a/src/gtk/hw.c	2010-06-05 14:45:33.672537694 +0200
++++ b/src/gtk/hw.c	2010-06-05 14:46:24.940536861 +0200
+@@ -719,7 +719,6 @@
+ /* Sets all Nvidia bios info */
+ void set_bios_info(GtkWidget *widget)
+ {
+-	char *tmp;
+ 	int i;
+ 	NVBios *bios = NV_BIOS(widget);
+ 	GtkTreeIter iter;
+@@ -943,7 +942,7 @@
+ 		{
+ 			desc = g_strdup_printf("-");
+ 			masked = g_strdup_printf("-");
+-			state = g_strdup_printf("");
++			state = g_strdup_printf("Unknown");
+ 		}
+ 
+ 		if((i >= 8) && (mask & 1<<i))
+@@ -963,7 +962,7 @@
+ 		{
+ 			desc = g_strdup_printf("-");
+ 			masked = g_strdup_printf("-");
+-			state = g_strdup_printf("");
++			state = g_strdup_printf("Unknown");
+ 		}
+ 		gtk_tree_store_append(pipeline->store, &iter, NULL);
+ 		gtk_tree_store_set(pipeline->store, &iter,
+@@ -1623,7 +1622,6 @@
+ {
+ 	NVThermal *thermal = g_object_new(NV_TYPE_THERMAL, NULL);
+ 	GtkWidget *hbox;
+-	int have_ambient;
+ 
+ 	thermal->card = card;
+ 	thermal->conf = conf;
+@@ -1748,7 +1746,6 @@
+ 	/* If opengl stuff isn't supported don't show it on the gui */
+ 	if(init_nvcontrol(dpy))
+ 	{
+-		int tmp;
+ 		NVGetAttribute(dpy, 0, 0, NV_IRQ, &irq);
+ 	}
+ #else
+Index: b/src/gtk/main.c
+===================================================================
+--- a/src/gtk/main.c	2010-06-05 14:45:33.672537694 +0200
++++ b/src/gtk/main.c	2010-06-05 14:46:24.940536861 +0200
+@@ -25,6 +25,7 @@
+ 
+ #include <stdlib.h>
+ #include <gtk/gtk.h>
++#include <X11/Xlib.h>
+ 
+ #include "banner.h"
+ #include "interface.h"
+Index: b/src/smartdimmer.c
+===================================================================
+--- a/src/smartdimmer.c	2010-06-05 14:45:33.700536566 +0200
++++ b/src/smartdimmer.c	2010-06-05 14:46:24.940536861 +0200
+@@ -35,6 +35,7 @@
+  * Erik Waling <erikw at acc.umu.se>                                             *
+  ******************************************************************************/
+ 
++#include <ctype.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <getopt.h>
+Index: b/src/backend/utils.c
+===================================================================
+--- a/src/backend/utils.c	2010-06-05 14:45:33.704537660 +0200
++++ b/src/backend/utils.c	2010-06-05 14:46:24.940536861 +0200
+@@ -20,6 +20,7 @@
+  */
+ 
+ #include <stdio.h>
++#include "nvclock.h"
+ 
+ /* Convert the gpu architecture to a string using NVxx/Gxx naming */
+ int convert_gpu_architecture(short arch, char *buf)
+@@ -78,3 +79,163 @@
+ 	}
+ 	buf[len] = 0;
+ }
++
++/* Internal gpu architecture function which sets
++/  a device to a specific architecture. This architecture
++/  doesn't have to be the real architecture. It is mainly
++/  used to choose codepaths inside nvclock.
++*/
++int get_gpu_arch(int device_id)
++{
++	int arch;
++	switch(device_id & 0xff0)
++	{
++		case 0x20:
++			arch = NV5;
++			break;
++		case 0x100:
++		case 0x110:
++		case 0x150:
++		case 0x1a0:
++			arch = NV10;
++			break;
++		case 0x170:
++		case 0x180:
++		case 0x1f0:
++			arch = NV17;
++			break;
++		case 0x200:
++			arch = NV20;
++			break;
++		case 0x250:
++		case 0x280:
++		case 0x320:	/* We don't treat the FX5200/FX5500 as FX cards */
++			arch = NV25;
++			break;
++		case 0x300:
++			arch = NV30;
++			break;
++		case 0x330:
++			arch = NV35; /* Similar to NV30 but fanspeed stuff works differently */
++			break;
++		/* Give a seperate arch to FX5600/FX5700 cards as they need different code than other FX cards */
++		case 0x310:
++		case 0x340:
++			arch = NV31;
++			break;
++		case 0x40:
++		case 0x120:
++		case 0x130:
++		case 0x210:
++		case 0x230:
++			arch = NV40;
++			break;
++		case 0xc0:
++			arch = NV41;
++			break;
++		case 0x140:
++			arch = NV43; /* Similar to NV40 but with different fanspeed code */
++			break;
++		case 0x160:
++		case 0x220:
++			arch = NV44;
++			break;
++		case 0x1d0:
++			arch = NV46;
++			break;
++		case 0x90:
++			arch = NV47;
++			break;
++		case 0x290:
++			arch = NV49; /* 7900 */
++			break;
++		case 0x390:
++			arch = NV4B; /* 7600 */
++			break;
++		case 0x190:
++			arch = NV50; /* 8800 'NV50 / G80' */
++			break;
++		case 0x400: /* 8600 'G84' */
++			arch = G84;
++			break;
++		case 0x420: /* 8500 'G86' */
++			arch = G86;
++			break;
++		case 0x5e0: /* GT2x0 */
++		case 0x5f0: /* GT2x0 */
++			arch = GT200;
++			break;
++		case 0x6e0: /* G98 */
++		case 0x6f0: /* G98 */
++		case 0x840: /* C7x */
++		case 0x850: /* C7x */
++		case 0x860: /* C79 */
++		case 0x870: /* C7x */
++			arch = G86;
++			break;
++		case 0x600: /* G92 */
++		case 0x610: /* G92 */
++			arch = G92;
++			break;
++		case 0x620: /* 9600GT 'G94' */
++			arch = G94;
++			break;
++		case 0x640: /* 9500GT */
++			arch = G96;
++			break;
++		case 0x240:
++		case 0x3d0: /* not sure if this is a C51 too */
++		case 0x530: /* not sure if the 70xx is C51 too */
++			arch = C51;
++			break;
++		case 0x2e0:
++		case 0xf0:
++			/* The code above doesn't work for pci-express cards as multiple architectures share one id-range */
++			switch(device_id)
++			{
++				case 0xf0: /* 6800 */
++				case 0xf9: /* 6800Ultra */
++					arch = NV40;
++					break;
++				case 0xf6: /* 6800GS/XT */
++					arch = NV41;
++					break;
++				case 0xf1: /* 6600/6600GT */
++				case 0xf2: /* 6600GT */
++				case 0xf3: /* 6200 */
++				case 0xf4: /* 6600LE */
++					arch = NV43;
++					break;
++				case 0xf5: /* 7800GS */
++					arch = NV47;
++					break;
++				case 0xfa: /* PCX5700 */
++					arch = NV31;
++					break;
++				case 0xf8: /* QuadroFX 3400 */
++				case 0xfb: /* PCX5900 */
++					arch = NV35;
++					break;
++				case 0xfc: /* PCX5300 */
++				case 0xfd: /* Quadro NVS280/FX330, FX5200 based? */
++				case 0xff: /* PCX4300 */
++					arch = NV25;
++					break;
++				case 0xfe: /* Quadro 1300, has the same id as a FX3000 */
++					arch = NV35;
++					break;
++				case 0x2e0: /* Geforce 7600GT AGP (at least Leadtek uses this id) */
++				case 0x2e1: /* Geforce 7600GS AGP (at least BFG uses this id) */
++				case 0x2e2: /* Geforce 7300GT AGP (at least a Galaxy 7300GT uses this id) */
++					arch = NV4B;
++					break;
++				case 0x2e4: /* Geforce 7950 GT AGP */
++					arch = NV49;
++					break;
++			}
++			break;
++		default:
++			arch = UNKNOWN;
++	}
++	return arch;
++}
+Index: b/src/backend/Makefile.in
+===================================================================
+--- a/src/backend/Makefile.in	2010-06-05 14:45:33.704537660 +0200
++++ b/src/backend/Makefile.in	2010-06-05 14:46:24.940536861 +0200
+@@ -11,9 +11,13 @@
+     OBJECTS+=back_bsd.o
+ else
+     ifeq ($(system), Win32)
+-	OBJECTS+=back_win32.o
++        OBJECTS+=back_win32.o
+     else
+-	OBJECTS+=back_linux.o
++        ifeq ($(system), SunOS)
++            OBJECTS+=back_solaris.o
++        else
++            OBJECTS+=back_linux.o
++        endif
+     endif
+ endif
+ 
+Index: b/src/backend/config.c
+===================================================================
+--- a/src/backend/config.c	2010-06-05 14:45:33.704537660 +0200
++++ b/src/backend/config.c	2010-06-05 14:46:24.940536861 +0200
+@@ -319,6 +319,11 @@
+ 	cfg_entry *pCfg = NULL;
+ 
+ 	pCfg = cfg;
++	if(!fp)
++	{
++		fprintf(stderr, "Unable to write configuration file to '%s'. Do you have sufficient permissions?\n", file);
++		return;
++	}
+ 
+ 	fprintf(fp, "#This is NVClock's config file. Don't edit the hw and general section!\n");
+ 	while(pCfg != NULL)
+Index: b/src/backend/nvreg.h
+===================================================================
+--- a/src/backend/nvreg.h	2010-06-05 14:45:33.704537660 +0200
++++ b/src/backend/nvreg.h	2010-06-05 14:46:24.940536861 +0200
+@@ -26,6 +26,7 @@
+ # define PCI_VENDOR_ID_SANYO 0x144d /* Samsung laptops use the Sanyo vendor id */
+ # define PCI_VENDOR_ID_SONY 0x104d
+ # define PCI_VENDOR_ID_ZEPTO 0x1a46
++# define PCI_VENDOR_ID_NVIDIA 0x10de
+ #define PCI_DEVICE_ID 0x2 /* 16-bit */
+ #define PCI_SUBSYSTEM_VENDOR_ID 0x2c /* 16-bit */
+ #define PCI_SUBSYSTEM_ID 0x2e /* 16-bit */
+@@ -58,6 +59,7 @@
+ #define PCIE_LINKSTATUS 0x12
+ # define PCIE_LINK_SPEED_MASK 0x3f0
+ # define PCIE_LINK_SPEED_SHIFT 4
++#define PCI_CLASS_VGA 0x3
+ 
+ /* PMC */
+ #define NV_PMC_BOOT_0 0x0
+Index: b/src/backend/nv40.c
+===================================================================
+--- a/src/backend/nv40.c	2010-06-05 14:45:33.704537660 +0200
++++ b/src/backend/nv40.c	2010-06-05 14:46:24.940536861 +0200
+@@ -68,6 +68,7 @@
+ 
+ #include <stdio.h>
+ #include <string.h>
++#include <unistd.h>
+ #include "backend.h"
+ 
+ /*
+Index: b/src/backend/backend.c
+===================================================================
+--- a/src/backend/backend.c	2010-06-05 14:45:33.704537660 +0200
++++ b/src/backend/backend.c	2010-06-05 14:46:24.940536861 +0200
+@@ -1,6 +1,6 @@
+ /* NVClock 0.8 - Linux overclocker for NVIDIA cards
+  * 
+- * Copyright(C) 2001-2007 Roderick Colenbrander
++ * Copyright(C) 2001-2009 Roderick Colenbrander
+  *
+  * site: http://nvclock.sourceforge.net
+  *
+@@ -29,6 +29,48 @@
+ #endif
+ #include "backend.h"
+ 
++int map_mem(const char *dev_name)
++{
++	dev_handle_t *fd = open_dev(dev_name);
++
++	if(!fd) /* open_dev has already set the error */
++		return 0;
++    
++	/* Map the registers of the nVidia chip */
++	nv_card->PEXTDEV = map_dev_mem(fd, nv_card->reg_address + 0x101000, 0x1000);
++	nv_card->PFB     = map_dev_mem(fd, nv_card->reg_address + 0x100000, 0x1000);
++	/* normally pmc is till 0x2000 but extended it for nv40 */
++	nv_card->PMC     = map_dev_mem(fd, nv_card->reg_address + 0x000000, 0x2ffff);
++	nv_card->PCIO    = map_dev_mem(fd, nv_card->reg_address + 0x601000, 0x2000);
++	nv_card->PDISPLAY = map_dev_mem(fd, nv_card->reg_address + NV_PDISPLAY_OFFSET, NV_PDISPLAY_SIZE);
++	nv_card->PRAMDAC = map_dev_mem(fd, nv_card->reg_address + 0x680000, 0x2000);
++	nv_card->PRAMIN  = map_dev_mem(fd, nv_card->reg_address + NV_PRAMIN_OFFSET, NV_PRAMIN_SIZE);
++	nv_card->PROM    = map_dev_mem(fd, nv_card->reg_address + 0x300000, 0xffff);
++
++	/* On Geforce 8xxx cards it appears that the pci config header has been moved */
++	if(nv_card->arch & NV5X)
++		nv_card->PBUS = map_dev_mem(fd, nv_card->reg_address + 0x88000, 0x100);
++	else
++		nv_card->PBUS = nv_card->PMC + 0x1800/4;
++
++	nv_card->mem_mapped = 1;
++
++	close_dev(fd);
++	return 1;
++}
++
++void unmap_mem()
++{
++	unmap_dev_mem((unsigned long)nv_card->PEXTDEV, 0x1000);
++	unmap_dev_mem((unsigned long)nv_card->PFB, 0x1000);
++	unmap_dev_mem((unsigned long)nv_card->PMC, 0x2ffff);
++	unmap_dev_mem((unsigned long)nv_card->PCIO, 0x2000);
++	unmap_dev_mem((unsigned long)nv_card->PDISPLAY, NV_PDISPLAY_SIZE);
++	unmap_dev_mem((unsigned long)nv_card->PRAMDAC, 0x2000);
++	unmap_dev_mem((unsigned long)nv_card->PRAMIN, NV_PRAMIN_SIZE);
++	unmap_dev_mem((unsigned long)nv_card->PROM, 0xffff);
++}
++
+ /* Read a byte from the pci bus */
+ unsigned char nv_read_pbus8(int offset)
+ {
+Index: b/src/backend/back_bsd.c
+===================================================================
+--- a/src/backend/back_bsd.c	2010-06-05 14:45:33.708537666 +0200
++++ b/src/backend/back_bsd.c	2010-06-05 14:46:24.940536861 +0200
+@@ -2,7 +2,7 @@
+  *
+  * Site: http://nvclock.sourceforge.net
+  *
+- * Copyright(C) 2001-2005 Roderick Colenbrander
++ * Copyright(C) 2001-2009 Roderick Colenbrander
+  * Portions Copyright(C) 2003 Samy Al Bahra  <samy at kerneled.com>
+  *
+  * This program is free software; you can redistribute it and/or modify
+@@ -41,8 +41,6 @@
+ #  include <sys/pciio.h>
+ #endif
+ 
+-#define NV_VENDOR 0x10de
+-#define VGA 0x03
+ #define SIZE 255
+ 
+ NVClock nvclock;
+@@ -90,8 +88,8 @@
+ 
+ 	memset(&pcidev,0,sizeof(pcidev));
+ 	pcidev.pat_buf_len=sizeof(patterns);
+-	patterns.pc_vendor=NV_VENDOR;
+-	patterns.pc_class=VGA;
++	patterns.pc_vendor=PCI_VENDOR_ID_NVIDIA;
++	patterns.pc_class=PCI_CLASS_VGA;
+ 	patterns.flags=PCI_GETCONF_MATCH_VENDOR|PCI_GETCONF_MATCH_CLASS;
+ 	pcidev.patterns=&patterns;
+ 	pcidev.num_patterns=1;
+@@ -183,8 +181,10 @@
+ 	return pi.pi_data;
+ }
+ 
+-int map_mem(const char *dev_name)
++/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
++dev_handle_t* open_dev(const char *dev_name)
+ {
++	dev_handle_t *dev;
+ 	int fd;
+ 
+ 	if( (fd = open(dev_name, O_RDWR)) == -1 )
+@@ -192,48 +192,29 @@
+ 		char err[80];
+ 		sprintf(err, "Can't open %s", dev_name);
+ 		set_error_str(err);
+-		return 0;
++		return NULL;
+ 	}
+-    
+-	/* Map the registers of the nVidia chip */
+-	nv_card->PEXTDEV = map_dev_mem(fd, nv_card->reg_address + 0x101000, 0x1000);
+-	nv_card->PFB     = map_dev_mem(fd, nv_card->reg_address + 0x100000, 0x1000);
+-	/* normally pmc is till 0x2000 but extended it for nv40 */
+-	nv_card->PMC     = map_dev_mem(fd, nv_card->reg_address + 0x000000, 0x2ffff);
+-	nv_card->PCIO    = map_dev_mem(fd, nv_card->reg_address + 0x601000, 0x2000);
+-	nv_card->PDISPLAY = map_dev_mem(fd, nv_card->reg_address + NV_PDISPLAY_OFFSET, NV_PDISPLAY_SIZE);
+-	nv_card->PRAMDAC = map_dev_mem(fd, nv_card->reg_address + 0x680000, 0x2000);
+-	nv_card->PRAMIN  = map_dev_mem(fd, nv_card->reg_address + NV_PRAMIN_OFFSET, NV_PRAMIN_SIZE);
+-	nv_card->PROM    = map_dev_mem(fd, nv_card->reg_address + 0x300000, 0xffff);
+-
+-	/* On Geforce 8xxx cards it appears that the pci config header has been moved */
+-	if(nv_card->arch & NV5X)
+-		nv_card->PBUS = map_dev_mem(fd, nv_card->reg_address + 0x88000, 0x100);
+-	else
+-		nv_card->PBUS = nv_card->PMC + 0x1800/4;
+ 
+-	nv_card->mem_mapped = 1;
+-	close(fd);
+-	return 1;
++	dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
++	dev->fd = fd;
++	return dev;
+ }
+ 
+-void unmap_mem()
++/* Close the devide handle */
++void close_dev(dev_handle_t *dev)
+ {
+-	unmap_dev_mem((unsigned long)nv_card->PEXTDEV, 0x1000);
+-	unmap_dev_mem((unsigned long)nv_card->PFB, 0x1000);
+-	unmap_dev_mem((unsigned long)nv_card->PMC, 0xffff);
+-	unmap_dev_mem((unsigned long)nv_card->PCIO, 0x2000);
+-	unmap_dev_mem((unsigned long)nv_card->PDISPLAY, NV_PDISPLAY_SIZE);
+-	unmap_dev_mem((unsigned long)nv_card->PRAMDAC, 0x2000);
+-	unmap_dev_mem((unsigned long)nv_card->PRAMIN, NV_PRAMIN_SIZE);
+-	unmap_dev_mem((unsigned long)nv_card->PROM, 0xffff);
++	if(!dev)
++		return;
++
++	close(dev->fd);
++	free(dev);
+ }
+ 
+ /* -------- mmap on devices -------- */
+ /* This piece of code is from nvtv a linux program for tvout */
+ /* The author of nvtv got this from xfree86's os-support/linux/lnx_video.c */
+ /* and he modified it a little  */
+-static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size)
++void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size)
+ {
+ 	void *base;
+ 	int mapflags = MAP_SHARED;
+@@ -243,10 +224,11 @@
+ 	alignOff = Base - realBase;
+ 
+ 	base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE,
+-	mapflags, fd, (off_t)realBase);
++	mapflags, dev->fd, (off_t)realBase);
+ 	return (void *) ((char *)base + alignOff);
+ }
+ 
++
+ static void unmap_dev_mem (unsigned long Base, unsigned long Size)
+ {
+ 	unsigned long alignOff = Base - (Base & ~(getpagesize() - 1));
+Index: b/src/backend/info.c
+===================================================================
+--- a/src/backend/info.c	2010-06-05 14:45:33.708537666 +0200
++++ b/src/backend/info.c	2010-06-05 14:46:24.944536740 +0200
+@@ -334,6 +334,7 @@
+ 	{ 0x5e0, "nvidia GeForce GT200-400", DESKTOP },
+ 	{ 0x5e1, "nvidia GeForce GTX 280", DESKTOP },
+ 	{ 0x5e2, "nvidia GeForce GTX 260", DESKTOP },
++	{ 0x5e3, "nvidia GeForce GTX 285", DESKTOP },
+ 	{ 0x5e7, "nvidia Tesla C1060", DESKTOP },
+ 	{ 0x5ed, "nvidia Quadroplex 2200 D2", DESKTOP },
+ 	{ 0x5f8, "nvidia Quadroplex 2200 S4", DESKTOP },
+@@ -351,11 +352,13 @@
+ 	{ 0x611, "nVidia Geforce 8800GT", DESKTOP },
+ 	{ 0x612, "nVidia Geforce 9800GTX", DESKTOP },
+ 	{ 0x614, "nVidia Geforce 9800GT", DESKTOP },
++	{ 0x615, "nVidia GeForce GTS 250", DESKTOP },
+ 	{ 0x61a, "nVidia QuadroFX 3700", DESKTOP },
+ 	{ 0x61c, "nVidia QuadroFX 3600M", MOBILE },
+ 	{ 0x622, "nVidia Geforce 9600GT", DESKTOP },
+ 	{ 0x623, "nVidia Geforce 9600GS", DESKTOP },
+ 	{ 0x640, "nVidia Geforce 9500GT", DESKTOP },
++	{ 0x641, "nVidia Geforce 9400GT", DESKTOP },
+ 	{ 0x643, "nVidia Geforce 9500GT", DESKTOP },
+ 	{ 0x647, "nVidia Geforce 9600M GT", MOBILE },
+ 	{ 0x648, "nVidia Geforce 9600M GS", MOBILE },
+@@ -398,6 +401,15 @@
+ 	{ 0x863, "nVidia Geforce 9400M", MOBILE },
+ 	{ 0x864, "nVidia Geforce 9300", DESKTOP },
+ 	{ 0x865, "nVidia Geforce 9300", DESKTOP },
++	{ 0x870, "NVIDIA GeForce 9400M", MOBILE },
++	{ 0x871, "NVIDIA GeForce 9200", MOBILE },
++	{ 0x872, "NVIDIA GeForce G102M", MOBILE },
++	{ 0x873, "NVIDIA GeForce G102M", MOBILE },
++	{ 0x874, "NVIDIA ION", NFORCE },
++	{ 0x876, "NVIDIA ION", NFORCE },
++	{ 0x87a, "NVIDIA Quadro FX 470", MOBILE },
++	{ 0x87d, "NVIDIA ION", NFORCE },
++	{ 0x87f, "NVIDIA MCP79", NFORCE },
+ 	{ 0, NULL, UNKNOWN }
+ };
+ 
+@@ -421,163 +433,6 @@
+ 	return "Unknown Nvidia card";
+ }
+ 
+-/* Internal gpu architecture function which sets
+-/  a device to a specific architecture. This architecture
+-/  doesn't have to be the real architecture. It is mainly
+-/  used to choose codepaths inside nvclock.
+-*/
+-int get_gpu_arch(int device_id)
+-{
+-	int arch;
+-	switch(device_id & 0xff0)
+-	{
+-		case 0x20:
+-			arch = NV5;
+-			break;
+-		case 0x100:
+-		case 0x110:
+-		case 0x150:
+-		case 0x1a0:
+-			arch = NV10;
+-			break;
+-		case 0x170:
+-		case 0x180:
+-		case 0x1f0:
+-			arch = NV17;
+-			break;
+-		case 0x200:
+-			arch = NV20;
+-			break;
+-		case 0x250:
+-		case 0x280:
+-		case 0x320:	/* We don't treat the FX5200/FX5500 as FX cards */
+-			arch = NV25;
+-			break;
+-		case 0x300:
+-			arch = NV30;
+-			break;
+-		case 0x330:
+-			arch = NV35; /* Similar to NV30 but fanspeed stuff works differently */
+-			break;
+-		/* Give a seperate arch to FX5600/FX5700 cards as they need different code than other FX cards */
+-		case 0x310:
+-		case 0x340:
+-			arch = NV31;
+-			break;
+-		case 0x40:
+-		case 0x120:
+-		case 0x130:
+-		case 0x210:
+-		case 0x230:
+-			arch = NV40;
+-			break;
+-		case 0xc0:
+-			arch = NV41;
+-			break;
+-		case 0x140:
+-			arch = NV43; /* Similar to NV40 but with different fanspeed code */
+-			break;
+-		case 0x160:
+-		case 0x220:
+-			arch = NV44;
+-			break;
+-		case 0x1d0:
+-			arch = NV46;
+-			break;
+-		case 0x90:
+-			arch = NV47;
+-			break;
+-		case 0x290:
+-			arch = NV49; /* 7900 */
+-			break;
+-		case 0x390:
+-			arch = NV4B; /* 7600 */
+-			break;
+-		case 0x190:
+-			arch = NV50; /* 8800 'NV50 / G80' */
+-			break;
+-		case 0x400: /* 8600 'G84' */
+-			arch = G84;
+-			break;
+-		case 0x420: /* 8500 'G86' */
+-			arch = G86;
+-			break;
+-		case 0x5e0: /* GT2x0 */
+-		case 0x5f0: /* GT2x0 */
+-			arch = GT200;
+-			break;
+-		case 0x6e0: /* G98 */
+-		case 0x6f0: /* G98 */
+-		case 0x860: /* C79 */
+-			arch = G86;
+-			break;
+-		case 0x600: /* G92 */
+-		case 0x610: /* G92 */
+-			arch = G92;
+-			break;
+-		case 0x620: /* 9600GT 'G94' */
+-			arch = G94;
+-			break;
+-		case 0x640: /* 9500GT */
+-			arch = G96;
+-			break;
+-		case 0x240:
+-		case 0x3d0: /* not sure if this is a C51 too */
+-		case 0x530: /* not sure if the 70xx is C51 too */
+-			arch = C51;
+-			break;
+-		case 0x2e0:
+-		case 0xf0:
+-			/* The code above doesn't work for pci-express cards as multiple architectures share one id-range */
+-			switch(device_id)
+-			{
+-				case 0xf0: /* 6800 */
+-				case 0xf9: /* 6800Ultra */
+-					arch = NV40;
+-					break;
+-				case 0xf6: /* 6800GS/XT */
+-					arch = NV41;
+-					break;
+-				case 0xf1: /* 6600/6600GT */
+-				case 0xf2: /* 6600GT */
+-				case 0xf3: /* 6200 */
+-				case 0xf4: /* 6600LE */
+-					arch = NV43;
+-					break;
+-				case 0xf5: /* 7800GS */
+-					arch = NV47;
+-					break;
+-				case 0xfa: /* PCX5700 */
+-					arch = NV31;
+-					break;
+-				case 0xf8: /* QuadroFX 3400 */
+-				case 0xfb: /* PCX5900 */
+-					arch = NV35;
+-					break;
+-				case 0xfc: /* PCX5300 */
+-				case 0xfd: /* Quadro NVS280/FX330, FX5200 based? */
+-				case 0xff: /* PCX4300 */
+-					arch = NV25;
+-					break;
+-				case 0xfe: /* Quadro 1300, has the same id as a FX3000 */
+-					arch = NV35;
+-					break;
+-				case 0x2e0: /* Geforce 7600GT AGP (at least Leadtek uses this id) */
+-				case 0x2e1: /* Geforce 7600GS AGP (at least BFG uses this id) */
+-				case 0x2e2: /* Geforce 7300GT AGP (at least a Galaxy 7300GT uses this id) */
+-					arch = NV4B;
+-					break;
+-				case 0x2e4: /* Geforce 7950 GT AGP */
+-					arch = NV49;
+-					break;
+-			}
+-			break;
+-		default:
+-			arch = UNKNOWN;
+-	}
+-	return arch;
+-}
+-
+ /* Receive the real gpu architecture */
+ static short get_gpu_architecture()
+ {
+Index: b/src/backend/back_solaris.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ b/src/backend/back_solaris.c	2010-06-05 14:46:24.944536740 +0200
+@@ -0,0 +1,205 @@
++/* NVClock 0.8 - OpenSolaris overclocker for NVIDIA cards
++ *
++ * Site: http://nvclock.sourceforge.net
++ *
++ * Solaris Backend: Copyright 2009 Bernd Markgraf <markgraf at med.ovgu.de>
++ * Copyright(C) 2001-2009 Roderick Colenbrander
++ *
++ * 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 <errno.h>
++#include <fcntl.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <stdint.h>
++#include <string.h>
++#include <sys/types.h>
++#include <sys/ioctl.h>
++#include <sys/param.h>
++#include <sys/mman.h>
++#include <pciaccess.h>
++#include <sys/pci.h>
++
++#include "backend.h"
++
++#define SIZE 255
++#define DEBUG 0
++
++NVClock nvclock;
++NVCard *nv_card = NULL;
++
++static int probe_devices();
++
++int init_nvclock()
++{
++	/* Check if the user is root */
++	if(getuid() != 0 && geteuid() != 0)
++	{
++		set_error(NV_ERR_NOT_ENOUGH_PERMISSIONS);
++		return 0;
++	}
++
++	/* Detect all nvidia cards; this needs to be done before creating directory and config file as that code needs card access */
++	if(!probe_devices())
++	{
++		/* probe_devices takes care of the error as it isn't certain it failed because of there are no nvidia cards */
++		return 0;
++	}
++
++	if(!open_config())
++		return 0;
++
++	return 1;
++}
++
++static int probe_devices()
++{
++	struct pci_device *pcidev;
++	struct pci_id_match *patterns;
++	struct pci_device_iterator *iter;
++
++	int counter=0;
++
++	pcidev=calloc(1, sizeof(struct pci_device));
++	patterns=calloc(1,sizeof(struct pci_id_match));
++  
++	patterns->vendor_id=PCI_VENDOR_ID_NVIDIA;
++	patterns->device_class=PCI_CLASS_VGA<<16;
++	patterns->device_id=PCI_MATCH_ANY;
++	patterns->subdevice_id=PCI_MATCH_ANY;
++	patterns->subvendor_id=PCI_MATCH_ANY;
++	patterns->device_class_mask=PCI_MATCH_ANY;
++  
++	pci_system_init();
++	iter = pci_id_match_iterator_create(patterns);
++	while (( pcidev = pci_device_next( iter )) != NULL )
++	{
++#if DEBUG
++		printf("count %d, vend 0x%x, dev 0x%x, class 0x%x\n",counter,pcidev->vendor_id,pcidev->device_id,pcidev->device_class>>16);
++#endif
++		nvclock.card[counter].device_id=pcidev->device_id;
++		nvclock.card[counter].dev_name= "/dev/xsvc";
++		nvclock.card[counter].card_name = (char*)get_card_name(nvclock.card[counter].device_id, &nvclock.card[counter].gpu);
++		nvclock.card[counter].arch = get_gpu_arch(nvclock.card[counter].device_id);
++		nvclock.card[counter].number = counter;
++		nvclock.card[counter].state = 0;
++		nvclock.card[counter].devbusfn = PCI_GET_DEVBUSFN(pcidev->dev, pcidev->bus, pcidev->func);
++		pci_device_probe( pcidev );
++#if DEBUG
++		int i;
++		for ( i = 0 ; i < 6 ; i++ ) 
++		{
++			if ( pcidev->regions[i].base_addr != 0 ) 
++			{
++				printf( "  BASE%u     0x%08x  addr 0x%08x  %s",
++					i,
++					0,
++					(intptr_t) pcidev->regions[i].base_addr,
++					(pcidev->regions[i].is_IO) ? "I/O" : "MEM" );
++
++				if ( ! pcidev->regions[i].is_IO )
++				{
++					if ( pcidev->regions[i].is_prefetchable )
++					{
++						printf( " PREFETCHABLE" );
++					}
++				}
++			
++				printf( "\n" );
++			}
++		}
++#endif
++		nvclock.card[counter].reg_address=pcidev->regions[0].base_addr;
++		counter++;
++	}
++
++	nvclock.num_cards = counter;
++
++	pci_system_cleanup();
++
++	return 1;
++}
++
++int32_t pciReadLong(unsigned short devbusfn, long offset)
++{
++	struct pci_device *pcidev;
++	int32_t data;
++
++	pci_system_init();
++	pcidev=pci_device_find_by_slot(0,PCI_GET_BUS(devbusfn),PCI_GET_DEVICE(devbusfn),PCI_GET_FUNCTION(devbusfn));
++#if DEBUG
++	printf("pciReadLong vend 0x%x, dev 0x%x, class 0x%x\n",pcidev->vendor_id,pcidev->device_id,pcidev->device_class>>16);
++#endif
++
++	pci_device_cfg_read_u32(pcidev,&data,offset);
++
++	pci_system_cleanup();
++	return data;
++}
++
++
++/* -------- mmap on devices -------- */
++/* This piece of code is from nvtv a linux program for tvout */
++/* The author of nvtv got this from xfree86's os-support/linux/lnx_video.c */
++/* and he modified it a little  */
++void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size)
++{
++	void *base;
++	int mapflags = MAP_SHARED;
++	unsigned long realBase, alignOff;
++
++	realBase = Base & ~(getpagesize() - 1);
++	alignOff = Base - realBase;
++
++	base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE, mapflags, dev->fd, (off_t)realBase);
++	return (void *) ((char *)base + alignOff);
++}
++
++void unmap_dev_mem (unsigned long Base, unsigned long Size)
++{
++	unsigned long alignOff = Base - (Base & ~(getpagesize() - 1));
++	munmap((caddr_t)(Base - alignOff), (Size + alignOff));
++	nv_card->mem_mapped = 0;
++}
++
++/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
++dev_handle_t* open_dev(const char *dev_name)
++{
++	dev_handle_t *dev;
++	int fd;
++
++	if( (fd = open(dev_name, O_RDWR)) == -1 )
++	{
++		char err[80];
++		sprintf(err, "Can't open %s", dev_name);
++		set_error_str(err);
++		return NULL;
++	}
++
++	dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
++	dev->fd = fd;
++	return dev;
++}
++
++/* Close the devide handle */
++void close_dev(dev_handle_t *dev)
++{
++	if(!dev)
++		return;
++
++	close(dev->fd);
++	free(dev);
++}
+Index: b/src/backend/backend.h
+===================================================================
+--- a/src/backend/backend.h	2010-06-05 14:45:33.708537666 +0200
++++ b/src/backend/backend.h	2010-06-05 14:46:24.944536740 +0200
+@@ -1,6 +1,6 @@
+ /* NVClock 0.8 - Linux overclocker for NVIDIA cards
+  * 
+- * Copyright(C) 2001-2005 Roderick Colenbrander
++ * Copyright(C) 2001-2009 Roderick Colenbrander
+  *
+  * site: http://nvclock.sourceforge.net
+  *
+@@ -42,12 +42,20 @@
+ /* Set the card object to the requested card */
+ int set_card(int number);
+ 
++/* This structure is used to abstract file descriptors away for mmap/unmmap. It will make sense when win32 support will be reactivated */
++typedef struct dev_handle
++{
++	int fd;
++} dev_handle_t;
++
+ /* Some internally needed functions */
+ const char* get_card_name(int device_id, gpu_type *gpu);
+ int get_gpu_arch(int device_id);
+ int set_card_info(int number); /* Basic version of set_card */
+-int map_mem(const char* dev_name);
+-void unmap_mem();
++dev_handle_t* open_dev(const char *dev_name);
++void close_dev(dev_handle_t *dev);
++void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size);
++void unmap_dev_mem (unsigned long Base, unsigned long Size);
+ int32_t pciReadLong(unsigned short devbusfn, long offset);
+ 
+ /* Bios related stuff */
+Index: b/src/backend/bios.c
+===================================================================
+--- a/src/backend/bios.c	2010-06-05 14:45:33.712537072 +0200
++++ b/src/backend/bios.c	2010-06-05 14:46:24.944536740 +0200
+@@ -48,6 +48,8 @@
+ static unsigned int locate(char *rom, char *str, int offset);
+ struct nvbios *read_bios(const char *file);
+ static struct nvbios *parse_bios(char *rom);
++int load_bios_file(const char* filename, char *data);
++int load_bios_prom(char *data);
+ 
+ typedef struct
+ {
+@@ -101,7 +103,6 @@
+ 	short i, num_entries;
+ 	unsigned char start;
+ 	unsigned char size;
+-	int tmp = 0;
+ 
+ 	/* read how far away the start is */
+ 	start = rom[offset];
+@@ -377,45 +378,12 @@
+ static void parse_bit_init_script_table(struct nvbios *bios, char *rom, int init_offset, int len)
+ {
+ 	int i,offset;
+-	int done=0;
+ 	unsigned char id;
+ 
++	/* Read all init tables and print some debug info */
+ 	/* Table 1 */
+ 	offset = READ_SHORT(rom, init_offset);
+ 
+-	/* For pipeline modding purposes we cache 0x1540 and for PLL generation the PLLs */
+-	id = rom[offset];
+-	while(id != 'q')
+-	{
+-		offset = bit_init_script_table_get_next_entry(rom, offset);
+-		/* Break out of the loop if we find an unknown entry id */
+-		if(!offset)
+-			break;
+-		id = rom[offset];
+-
+-		if(id == 'z')
+-		{
+-			int reg = READ_INT(rom, offset+1);
+-			unsigned int val = READ_INT(rom, offset+5);
+-			switch(reg)
+-			{
+-				case 0x1540:
+-					bios->pipe_cfg = val;
+-					break;
+-				case 0x4000:
+-					bios->nvpll = val;
+-					break;
+-				case 0x4020:
+-					bios->mpll = val;
+-					break;
+-			}
+-		}
+-	}
+-
+-#if DEBUG /* Read all init tables and print some debug info */
+-/* Table 1 */
+-	offset = READ_SHORT(rom, init_offset);
+-
+ 	for(i=0; i<=len; i+=2)
+ 	{
+ 		/* Not all tables have to exist */
+@@ -426,7 +394,9 @@
+ 			continue;
+ 		}
+ 
++#if DEBUG
+ 		printf("Init script table %d\n", i/2+1);
++#endif
+ 		id = rom[offset];
+ 
+ 		while(id != 'q')
+@@ -435,10 +405,33 @@
+ 			if(!offset)
+ 				break;
+ 
++#if DEBUG
+ 			if(!(id == 'K' || id == 'n' || id == 'x' || id == 'y' || id == 'z'))
+ 				printf("'%c' (%x)\n", id, id);
++#endif
+ 			offset = bit_init_script_table_get_next_entry(rom, offset);
+ 			id = rom[offset];
++
++			if(id == 'z')
++			{
++				int reg = READ_INT(rom, offset+1);
++				unsigned int val = READ_INT(rom, offset+5);
++				switch(reg)
++				{
++					case 0x1540:
++						bios->pipe_cfg = val;
++						break;
++					case 0x4000:
++						bios->nvpll = val;
++						break;
++					case 0x4020:
++						bios->mpll = val;
++						break;
++					case (NV_PDISPLAY_OFFSET + NV_PDISPLAY_SOR0_REGS_BRIGHTNESS):
++						bios->pdisplay_brightness = val;
++						break;
++				}
++			}
+ 		}
+ 
+ 		/* Pointer to next init table */
+@@ -446,8 +439,6 @@
+ 		/* Get location of next table */
+ 		offset = READ_SHORT(rom, init_offset);
+ 	}
+-#endif
+-
+ }
+ 
+ 
+@@ -881,55 +872,6 @@
+ 	return 0;
+ }
+ 
+-
+-#if DEBUG
+-int main(int argc, char **argv)
+-{
+-	read_bios("bios.rom");
+-	return 0;
+-}
+-
+-
+-#else
+-void dump_bios(const char *filename)
+-{
+-	int i;
+-	FILE *fp = NULL;
+-	char *rom = calloc(NV_PROM_SIZE, sizeof(char));
+-
+-	if(!rom)
+-	{
+-		fprintf(stderr, "Unable to allocate memory for shadowing the bios image\n");
+-		return;
+-	}
+-
+-	/* Try to obtain a copy of the bios first from PRAMIN later from the (slow) ROM.
+-	/  Dumping from ROM might fail on laptops as for some reason there is no ROM on some laptops.
+-	*/
+-	if(!load_bios_pramin(rom))
+-	{
+-		if(!load_bios_prom(rom))
+-		{
+-			fprintf(stderr, "Unable to shadow the video bios\n");
+-			free(rom);
+-			return;
+-		}
+-	}
+-
+-	/* Try to dump the bios to a file */
+-	fp = fopen(filename, "w+");
+-	if(!fp) return;
+-
+-	for(i=0; i<NV_PROM_SIZE; i++)
+-	{
+-		fprintf(fp, "%c", rom[i]);
+-	}
+-	fclose(fp);
+-
+-	free(rom);
+-}
+-#endif
+-
+ /* Verify if we are dealing with a valid bios image */
+ int verify_bios(char *rom)
+ {
+@@ -946,7 +888,6 @@
+ int load_bios_file(const char* filename, char *data)
+ {
+ 	int fd = 0;
+-	int i = 0;
+ 	char *rom = NULL;
+ 
+ 	if((fd = open(filename, O_RDONLY)) == -1)
+@@ -969,10 +910,10 @@
+ 		return 0;
+ }
+ 
++#ifndef DEBUG
+ /* Load the bios from video memory. Note it might not be cached there at all times. */
+ int load_bios_pramin(char *data)
+ {
+-	int i;
+ 	char *bios;
+ 	uint32_t old_bar0_pramin = 0;
+ 
+@@ -1041,6 +982,7 @@
+ 	else
+ 		return 0;
+ }
++#endif
+ 
+ /* This function tries to read a copy of the bios from harddrive. If that doesn't
+  exist it will dump the bios and then read it. You might wonder why we don't read the bios from
+@@ -1055,6 +997,13 @@
+ 	if(!rom)
+ 		return NULL;
+ 
++#if DEBUG
++	if(!load_bios_file(file, rom))
++	{
++		free(rom);
++		return NULL;
++	}
++#else
+ 	if(!load_bios_pramin(rom))
+ 	{
+ 		if(!load_bios_file(file, rom))
+@@ -1063,6 +1012,7 @@
+ 			return NULL;
+ 		}
+ 	}
++#endif
+ 
+ 	/* Do the actual bios parsing */
+ 	res = parse_bios(rom);
+@@ -1098,7 +1048,7 @@
+ 	device_id = READ_SHORT(rom, pcir_offset + 6);
+ 	if(get_gpu_arch(device_id) & (NV4X | NV5X))
+ 	{
+-	/* For NV40 card the BIT structure is used instead of the BMP structure (last one doesn't exist anymore on 6600/6800le cards). */
++		/* For NV40 card the BIT structure is used instead of the BMP structure (last one doesn't exist anymore on 6600/6800le cards). */
+ 		if(!(bit_offset = locate(rom, "BIT", 0)))
+ 			return NULL;
+ 
+@@ -1189,3 +1139,49 @@
+ #endif
+ 	return bios;
+ }
++
++#if DEBUG
++int main(int argc, char **argv)
++{
++	read_bios("bios.rom");
++	return 0;
++}
++#else
++void dump_bios(const char *filename)
++{
++	int i;
++	FILE *fp = NULL;
++	char *rom = calloc(NV_PROM_SIZE, sizeof(char));
++
++	if(!rom)
++	{
++		fprintf(stderr, "Unable to allocate memory for shadowing the bios image\n");
++		return;
++	}
++
++	/* Try to obtain a copy of the bios first from PRAMIN later from the (slow) ROM.
++	/  Dumping from ROM might fail on laptops as for some reason there is no ROM on some laptops.
++	*/
++	if(!load_bios_pramin(rom))
++	{
++		if(!load_bios_prom(rom))
++		{
++			fprintf(stderr, "Unable to shadow the video bios\n");
++			free(rom);
++			return;
++		}
++	}
++
++	/* Try to dump the bios to a file */
++	fp = fopen(filename, "w+");
++	if(!fp) return;
++
++	for(i=0; i<NV_PROM_SIZE; i++)
++	{
++		fprintf(fp, "%c", rom[i]);
++	}
++	fclose(fp);
++
++	free(rom);
++}
++#endif
+Index: b/src/backend/nvclock.h
+===================================================================
+--- a/src/backend/nvclock.h	2010-06-05 14:45:33.712537072 +0200
++++ b/src/backend/nvclock.h	2010-06-05 14:46:24.944536740 +0200
+@@ -179,6 +179,8 @@
+ 	unsigned int spll;
+ 
+ 	unsigned int pipe_cfg; /* Used to cache the NV4x pipe_cfg register */
++
++	unsigned int pdisplay_brightness; /* Used for NV5x smartdimmer */
+ };
+ 
+ typedef struct {
+@@ -248,7 +250,7 @@
+ 
+ 	/* Hardware monitoring */
+ 	short num_busses; /* Number of available i2c busses */
+-	I2CBusPtr busses[3]; /* I2C busses on the videocard; this bus is needed for communication with sensor chips */
++	I2CBusPtr busses[4]; /* I2C busses on the videocard; this bus is needed for communication with sensor chips */
+ 	I2CDevPtr sensor; /* When a sensor chip is available, this device pointer can be used to access it */
+ 	char *sensor_name; /* Name of the sensor; although sensor contains the name too, we add sensor_name because of the builtin temperature sensor used on various NV4x cards */
+ 	int (*get_board_temp)(I2CDevPtr dev); /* Temperature of the sensor chip or for example the ram chips */
+Index: b/src/backend/back_linux.c
+===================================================================
+--- a/src/backend/back_linux.c	2010-06-05 14:45:33.720536632 +0200
++++ b/src/backend/back_linux.c	2010-06-05 14:46:24.944536740 +0200
+@@ -1,6 +1,6 @@
+ /* NVClock 0.8 - Linux overclocker for NVIDIA cards
+  * 
+- * Copyright(C) 2001-2007 Roderick Colenbrander
++ * Copyright(C) 2001-2009 Roderick Colenbrander
+  *
+  * site: http://nvclock.sourceforge.net
+  *
+@@ -37,8 +37,6 @@
+ static int IsVideoCard(unsigned short devbusfn);
+ 
+ static int probe_devices();
+-static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size);
+-static void unmap_dev_mem (unsigned long Base, unsigned long Size);
+ 
+ /* Check if we are using the closed source Nvidia drivers */
+ static int check_driver()
+@@ -62,7 +60,7 @@
+ 		/  For various versions the driver isn't initialized when X hasn't
+ 		/  been started and it can crash then.
+ 		*/
+-		if(sscanf(buffer,"%s %d %d",&name, &size, &used) != 3) continue;
++		if(sscanf(buffer,"%s %d %d", name, &size, &used) != 3) continue;
+ 		{
+ 			if(strcmp(name, "NVdriver") == 0)
+ 			{
+@@ -131,7 +129,7 @@
+ 		if(sscanf(buf,"%hx %x %x %x",&devbusfn, &dev, &irq, &reg_addr) != 4) continue;
+ 
+ 		/* Check if the card contains an Nvidia chipset */	
+-		if((dev>>16) == 0x10de)
++		if((dev>>16) == PCI_VENDOR_ID_NVIDIA)
+ 		{
+ 			/*
+ 			When we enter this block of code we know that the device contains some 
+@@ -199,8 +197,8 @@
+ static int IsVideoCard(unsigned short devbusfn)
+ {
+ 	int32_t pci_class = pciReadLong(devbusfn, 0x9);
+-	/* When the id isn't 0x03 the card isn't a vga card return 0 */
+-	if(((htonl(pci_class) >> 8) & 0xf) != 0x03)
++	/* When the id isn't PCI_CLASS_VGA the card isn't a vga card return 0 */
++	if(((htonl(pci_class) >> 8) & 0xf) != PCI_CLASS_VGA)
+ 		return 0;
+ 	else
+ 		return 1;
+@@ -228,8 +226,10 @@
+ 	return -1;
+ }
+ 
+-int map_mem(const char *dev_name)
++/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
++dev_handle_t* open_dev(const char *dev_name)
+ {
++	dev_handle_t *dev;
+ 	int fd;
+ 
+ 	if( (fd = open(dev_name, O_RDWR)) == -1 )
+@@ -237,48 +237,29 @@
+ 		char err[80];
+ 		sprintf(err, "Can't open %s", dev_name);
+ 		set_error_str(err);
+-		return 0;
++		return NULL;
+ 	}
+-    
+-	/* Map the registers of the nVidia chip */
+-	nv_card->PEXTDEV = map_dev_mem(fd, nv_card->reg_address + 0x101000, 0x1000);
+-	nv_card->PFB     = map_dev_mem(fd, nv_card->reg_address + 0x100000, 0x1000);
+-	/* normally pmc is till 0x2000 but extended it for nv40 */
+-	nv_card->PMC     = map_dev_mem(fd, nv_card->reg_address + 0x000000, 0x2ffff);
+-	nv_card->PCIO    = map_dev_mem(fd, nv_card->reg_address + 0x601000, 0x2000);
+-	nv_card->PDISPLAY = map_dev_mem(fd, nv_card->reg_address + NV_PDISPLAY_OFFSET, NV_PDISPLAY_SIZE);
+-	nv_card->PRAMDAC = map_dev_mem(fd, nv_card->reg_address + 0x680000, 0x2000);
+-	nv_card->PRAMIN  = map_dev_mem(fd, nv_card->reg_address + NV_PRAMIN_OFFSET, NV_PRAMIN_SIZE);
+-	nv_card->PROM    = map_dev_mem(fd, nv_card->reg_address + 0x300000, 0xffff);
+-
+-	/* On Geforce 8xxx cards it appears that the pci config header has been moved */
+-	if(nv_card->arch & NV5X)
+-		nv_card->PBUS = map_dev_mem(fd, nv_card->reg_address + 0x88000, 0x100);
+-	else
+-		nv_card->PBUS = nv_card->PMC + 0x1800/4;
+ 
+-	nv_card->mem_mapped = 1;
+-	close(fd);
+-	return 1;
++	dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
++	dev->fd = fd;
++	return dev;
+ }
+ 
+-void unmap_mem()
++/* Close the devide handle */
++void close_dev(dev_handle_t *dev)
+ {
+-	unmap_dev_mem((unsigned long)nv_card->PEXTDEV, 0x1000);
+-	unmap_dev_mem((unsigned long)nv_card->PFB, 0x1000);
+-	unmap_dev_mem((unsigned long)nv_card->PMC, 0xffff);
+-	unmap_dev_mem((unsigned long)nv_card->PCIO, 0x2000);
+-	unmap_dev_mem((unsigned long)nv_card->PDISPLAY, NV_PDISPLAY_SIZE);
+-	unmap_dev_mem((unsigned long)nv_card->PRAMDAC, 0x2000);
+-	unmap_dev_mem((unsigned long)nv_card->PRAMIN, NV_PRAMIN_SIZE);
+-	unmap_dev_mem((unsigned long)nv_card->PROM, 0xffff);
++	if(!dev)
++		return;
++
++	close(dev->fd);
++	free(dev);
+ }
+ 
+ /* -------- mmap on devices -------- */
+ /* This piece of code is from nvtv a linux program for tvout */
+ /* The author of nvtv got this from xfree86's os-support/linux/lnx_video.c */
+ /* and he modified it a little  */
+-static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size)
++void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size)
+ {
+ 	void *base;
+ 	int mapflags = MAP_SHARED;
+@@ -288,11 +269,11 @@
+ 	alignOff = Base - realBase;
+ 
+ 	base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE,
+-	mapflags, fd, (off_t)realBase);
++	mapflags, dev->fd, (off_t)realBase);
+ 	return (void *) ((char *)base + alignOff);
+ }
+ 
+-static void unmap_dev_mem (unsigned long Base, unsigned long Size)
++void unmap_dev_mem (unsigned long Base, unsigned long Size)
+ {
+ 	unsigned long alignOff = Base - (Base & ~(getpagesize() - 1));
+ 	munmap((caddr_t)(Base - alignOff), (Size + alignOff));
+Index: b/src/backend/back_win32.c
+===================================================================
+--- a/src/backend/back_win32.c	2010-06-05 14:45:33.720536632 +0200
++++ b/src/backend/back_win32.c	2010-06-05 14:46:24.944536740 +0200
+@@ -1,6 +1,6 @@
+ /* NVClock 0.8 - Linux overclocker for NVIDIA cards
+  * 
+- * Copyright(C) 2001-2007 Roderick Colenbrander
++ * Copyright(C) 2001-2009 Roderick Colenbrander
+  *
+  * site: http://nvclock.sourceforge.net
+  *
+@@ -57,7 +57,7 @@
+ 	if(lib_memacc == NULL)
+ 	{
+ 		set_error_str("Can't open MemAcc.dll\n");
+-	return 0;
++		return 0;
+ 	}
+ 
+ 	pOpenLibrary = (void*)GetProcAddress(lib_memacc, "maOpenLibrary");
+@@ -100,7 +100,7 @@
+ 		/* Check whether the vendor is nvidia and the BaseClass == VGA */
+ 		if(vendor_id == 0x10de && pCfg.BaseClass == 0x3)
+ 		{
+-			printf("Found VendorID: 0x%x DeviceID: 0x%x\r\n", vendor_id, device_id);
++//			printf("Found VendorID: 0x%x DeviceID: 0x%x\r\n", vendor_id, device_id);
+ 			
+ 			nvclock.card[i].device_id = device_id;
+ 			nvclock.card[i].arch = get_gpu_arch(nvclock.card[i].device_id);
+@@ -126,38 +126,30 @@
+ 	return -1;
+ }
+ 
+-int map_mem(const char *dev_name)
++/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
++dev_handle_t* open_dev(const char *dev_name)
++{
++	dev_handle_t *dev;
++
++	dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
++//	dev->fd = fd;
++	return dev;
++}
++
++/* Close the devide handle */
++void close_dev(dev_handle_t *dev)
+ {
+-	void *hmem; // do nothing with this for now
+-	/* Map the registers of the nVidia chip */
+-	nv_card->PEXTDEV = pMapPhysToLinear(nv_card->reg_address + 0x101000, 0x1000, &hmem);
+-	nv_card->PFB	 = pMapPhysToLinear(nv_card->reg_address + 0x100000, 0x1000, &hmem);
+-	/* normally pmc is till 0x2000 but extended it for nv40 */
+-	nv_card->PMC	 = pMapPhysToLinear(nv_card->reg_address + 0x000000, 0x2ffff, &hmem);
+-	nv_card->PCIO	= pMapPhysToLinear(nv_card->reg_address + 0x601000, 0x2000, &hmem);
+-	nv_card->PDISPLAY = pMapPhysToLinear(nv_card->reg_address + NV_PDISPLAY, NV_PDISPLAY_LENGTH, &hmem);
+-	nv_card->PRAMDAC = pMapPhysToLinear(nv_card->reg_address + 0x680000, 0x2000, &hmem);
+-	nv_card->PROM	= pMapPhysToLinear(nv_card->reg_address + 0x300000, 0xffff, &hmem);
+-
+-	/* On Geforce 8xxx cards it appears that the pci config header has been moved */
+-	if(nv_card->arch & NV5X)
+-		nv_card->PBUS = pMapPhysToLinear(nv_card->reg_address + 0x88000, 0x100, &hmem);
+-	else
+-		nv_card->PBUS = nv_card->PMC + 0x1800/4;
+ 
+-	nv_card->mem_mapped = 1;
+-	return 1;
+ }
+ 
+-void unmap_mem()
++void *map_dev_mem(dev_handle_t *dev, unsigned long Base, unsigned long Size)
+ {
+-#if 0
+-	pUnMapIO(winio, (void*)nv_card->PEXTDEV);
+-	pUnMapIO(winio, (void*)nv_card->PFB);
+-	pUnMapIO(winio, (void*)nv_card->PMC);
+-	pUnMapIO(winio, (void*)nv_card->PCIO);
+-	pUnMapIO(winio, (void*)nv_card->PRAMDAC);
+-	pUnMapIO(winio, (void*)nv_card->PROM);
+-	nv_card->mem_mapped = 0;
+-#endif
++	void *hmem;
++	return pMapPhysToLinear(Base, Size, &hmem);
++}
++
++
++void unmap_dev_mem(unsigned long Base, unsigned long Size)
++{
++
+ }
+Index: b/src/backend/w83781d.c
+===================================================================
+--- a/src/backend/w83781d.c	2010-06-05 14:45:33.728536611 +0200
++++ b/src/backend/w83781d.c	2010-06-05 14:46:24.944536740 +0200
+@@ -73,9 +73,11 @@
+ 
+ float w83781d_get_fanspeed_pwm(I2CDevPtr dev)
+ {
++	return 0.0;
+ }
+ 
+ int w83781d_set_fanspeed_pwm(I2CDevPtr dev, float speed)
+ {
++	return 0;
+ }
+ 
+Index: b/src/backend/nv30.c
+===================================================================
+--- a/src/backend/nv30.c	2010-06-05 14:45:33.736536575 +0200
++++ b/src/backend/nv30.c	2010-06-05 14:46:24.944536740 +0200
+@@ -178,7 +178,7 @@
+ static void nv30_set_gpu_speed(unsigned int nvclk)
+ {
+ 	unsigned int PLL=0;
+-	int m1, m2, n1, n2, p;
++	unsigned int m1, m2, n1, n2, p;
+ 	nvclk *= 1000;
+ 
+ 	p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
+@@ -200,7 +200,7 @@
+ static void nv31_set_gpu_speed(unsigned int nvclk)
+ {
+ 	unsigned int PLL, PLL2;
+-	int m1, m2, n1, n2, p;
++	unsigned int m1, m2, n1, n2, p;
+ 	nvclk *= 1000;
+ 
+ 	p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
+@@ -241,7 +241,7 @@
+ static void nv30_set_memory_speed(unsigned int memclk)
+ {
+ 	unsigned int PLL=0;
+-	int m1, m2, n1, n2, p;
++	unsigned int m1, m2, n1, n2, p;
+ 	memclk *= 1000;
+ 
+ 	p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
+@@ -260,7 +260,7 @@
+ static void nv31_set_memory_speed(unsigned int memclk)
+ {
+ 	unsigned int PLL, PLL2;
+-	int m1, m2, n1, n2, p;
++	unsigned int m1, m2, n1, n2, p;
+ 	memclk *= 1000;
+ 
+ 	p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
+Index: b/src/backend/nv50.c
+===================================================================
+--- a/src/backend/nv50.c	2010-06-05 14:45:33.736536575 +0200
++++ b/src/backend/nv50.c	2010-06-05 14:46:24.944536740 +0200
+@@ -166,13 +166,18 @@
+ 	if(speed < 10 || speed > 100)
+ 		return;
+ 
++	/* Note Oxe300 is also related to the fanspeed. By default it seems to contain 0x100 on
++	/  9600GT and other cards. Setting this value to 0x300 seems to set the fanspeed to a fixed
++	/  value. Apparently 0xe300 acts like a multiplexer?
++	/  On some boards this magical bit9 (0x200) is set by the drivers sometimes which prevents
++	/  fanspeed adjustment. Clear this bet when needed.
++	*/
++	if(nv_card->PMC[0xe300/4] & (1<<9))
++		nv_card->PMC[0xe300/4] &= ~(1<<9);
++
+ 	/* Bit31 must be set else the hardware doesn't seem to do anything with the changes
+ 	/  Bit30-16 contain some magical bits on 9500GT and other cards which we should preserve.
+ 	/  On a 9500gt the contents of 0xe120 could be e.g. 0x0300010e with a pwm_divider of 0x21d.
+-	/
+-	/  Note Oxe300 is also related to the fanspeed. By default it seems to contain 0x100 on
+-	/  9600GT and other cards. Setting this value to 0x300 seems to set the fanspeed to a fixed
+-	/  value. Apparently 0xe300 acts like a multiplexer?
+ 	*/
+ 	value = 0x80000000 | (nv_card->PMC[0xe120/4] & 0x7fff0000) | (((int)(100 - speed) * pwm_divider/100) & 0x7fff);
+ 	nv_card->PMC[0xe120/4] = value;
+@@ -404,12 +409,16 @@
+ 	/   FZ21E, FZ21M, FZ470E, FZ340E, FZ190N, FZ18M, FZ31E, FZ18E, FZ31Z, FZ21Z, FZ31S, AR51SU, AR71S
+ 	/ - Zepto (unknown model), Geforce 9600M, dev=0x649, subvendor=0x1a46, 
+ 	*/
++#if 0
+ 	if((nv_card->gpu == MOBILE) &&
+ 		((nv_card->subvendor_id == PCI_VENDOR_ID_APPLE) ||
+ 		 (nv_card->subvendor_id == PCI_VENDOR_ID_HP) ||
+ 		 (nv_card->subvendor_id == PCI_VENDOR_ID_SANYO) ||
+ 		 (nv_card->subvendor_id == PCI_VENDOR_ID_SONY) ||
+ 		 (nv_card->subvendor_id == PCI_VENDOR_ID_ZEPTO)))
++#endif
++	/* Detect the presence of smartdimmer depending on whether the bios initialized the register */
++	if(nv_card->bios && nv_card->bios->pdisplay_brightness)
+ 	{
+ 		nv_card->caps |= SMARTDIMMER;
+ 		nv_card->get_smartdimmer = nv50_mobile_get_smartdimmer;

Added: packages/nvclock/trunk/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-nvidia/packages/nvclock/trunk/debian/patches/series?rev=1020&op=file
==============================================================================
--- packages/nvclock/trunk/debian/patches/series (added)
+++ packages/nvclock/trunk/debian/patches/series Sat Jun  5 13:27:14 2010
@@ -1,0 +1,1 @@
+cvs-2009-06-22.diff




More information about the Pkg-nvidia-devel mailing list