Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2011
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.97 KB | None | 0 0
  1. Description: updates from upstream CVS up to 2009-06-22
  2. This patch includes all changes between the 0.8b4 tarball and the upstream
  3. CVS repository as of 2009-06-22 (date of last commit).
  4. Origin: upstream, http://nvclock.cvs.sourceforge.net/viewvc/nvclock/
  5. Last-Update: 2010-06-05
  6.  
  7. Index: b/Makefile.in
  8. ===================================================================
  9. --- a/Makefile.in 2010-06-05 14:45:33.624537043 +0200
  10. +++ b/Makefile.in 2010-06-05 14:46:24.936536570 +0200
  11. @@ -1,10 +1,14 @@
  12. INSTALL=@INSTALL@
  13. +DESTDIR =
  14. +prefix=@prefix@
  15. +docdir=@docdir@
  16. +mandir=@mandir@
  17.  
  18. -prefix=$(DESTDIR)@prefix@
  19. -docdir=${prefix}/share/doc/nvclock
  20. -mandir=${prefix}/man
  21. DOCS= ABOUT AUTHORS ChangeLog FAQ README
  22.  
  23. +CFLAGS=@CFLAGS@
  24. +CXXFLAGS=@CXXFLAGS@
  25. +
  26. all:
  27. $(MAKE) -C src all
  28.  
  29. @@ -21,7 +25,7 @@
  30. install-docs:
  31. @documentations='$(DOCS)'; \
  32. for doc in $$documentations; do \
  33. - destdir=$(docdir); \
  34. + destdir=$(DESTDIR)$(docdir); \
  35. name=`echo $$doc` \
  36. dir=$$destdir; \
  37. mkdir -p $$dir; \
  38. @@ -30,14 +34,14 @@
  39. done
  40.  
  41. install-desktop-shortcut:
  42. - mkdir -p $(prefix)/share/applications
  43. - mkdir -p $(prefix)/share/icons/hicolor/48x48/apps
  44. - cp nvclock.desktop $(prefix)/share/applications
  45. - cp nvclock.png $(prefix)/share/icons/hicolor/48x48/apps
  46. + mkdir -p $(DESTDIR)$(prefix)/share/applications
  47. + mkdir -p $(DESTDIR)$(prefix)/share/icons/hicolor/48x48/apps
  48. + cp nvclock.desktop $(DESTDIR)$(prefix)/share/applications
  49. + cp nvclock.png $(DESTDIR)$(prefix)/share/icons/hicolor/48x48/apps
  50.  
  51. install-man:
  52. - mkdir -p $(mandir)/man1
  53. - cp nvclock.1 $(mandir)/man1
  54. + mkdir -p $(DESTDIR)$(mandir)/man1
  55. + cp nvclock.1 $(DESTDIR)$(mandir)/man1
  56.  
  57. uninstall: uninstall-docs uninstall-man uninstall-desktop-shortcut
  58. $(MAKE) -C src uninstall
  59. @@ -45,7 +49,7 @@
  60. uninstall-docs:
  61. @documentations='$(DOCS)'; \
  62. for doc in $$documentations; do \
  63. - destdir=$(docdir); \
  64. + destdir=$(DESTDIR)$(docdir); \
  65. name=`echo $$doc` \
  66. dir=$$destdir; \
  67. rm -f $$dir/$$name; \
  68. @@ -53,11 +57,12 @@
  69. done
  70.  
  71. uninstall-desktop-shortcut:
  72. - rm -f $(prefix)/share/applications/nvclock.desktop
  73. - echo "removing $$prefix/share/applications/nvclock.desktop" ; \
  74. - rm -f $(prefix)/share/icons/hicolor/48x48/apps/nvclock.png
  75. - echo "removing $$prefix/share/icons/hicolor/48x48/apps/nvclock.png" ; \
  76. + rm -f $(DESTDIR)$(prefix)/share/applications/nvclock.desktop
  77. + echo "removing $$(DESTDIR)$$prefix/share/applications/nvclock.desktop" ; \
  78. + rm -f $(DESTDIR)$(prefix)/share/icons/hicolor/48x48/apps/nvclock.png
  79. + echo "removing $$(DESTDIR)$$prefix/share/icons/hicolor/48x48/apps/nvclock.png" ; \
  80.  
  81. uninstall-man:
  82. - rm -f $(mandir)/man1/nvclock.1
  83. - echo "removing $$mandir/man1/nvclock.1" ; \
  84. + rm -f $$(DESTDIR)$(mandir)/man1/nvclock.1
  85. + echo "removing $$(DESTDIR)$$mandir/man1/nvclock.1" ; \
  86. +
  87. Index: b/configure.in
  88. ===================================================================
  89. --- a/configure.in 2010-06-05 14:45:33.628537683 +0200
  90. +++ b/configure.in 2010-06-05 14:46:24.936536570 +0200
  91. @@ -12,7 +12,6 @@
  92. AC_HEADER_STDC
  93.  
  94.  
  95. -CFLAGS=
  96. HAVE_GTK2=no
  97. HAVE_QT=no
  98. HAVE_NVCONTROL=no
  99. Index: b/src/nvclock.c
  100. ===================================================================
  101. --- a/src/nvclock.c 2010-06-05 14:45:33.628537683 +0200
  102. +++ b/src/nvclock.c 2010-06-05 14:46:24.936536570 +0200
  103. @@ -117,7 +117,7 @@
  104.  
  105. char *mask_to_device(int mask)
  106. {
  107. - char *res;
  108. + char *res = NULL;
  109. int i=0;
  110. if(mask & NV_CRT)
  111. {
  112. @@ -942,7 +942,7 @@
  113.  
  114. if(fanspeed_opt && force_opt)
  115. {
  116. - float dutycycle;
  117. + float dutycycle = 0.0;
  118.  
  119. if(!(nv_card->caps & (GPU_FANSPEED_MONITORING | I2C_FANSPEED_MONITORING)))
  120. {
  121. Index: b/src/Makefile.in
  122. ===================================================================
  123. --- a/src/Makefile.in 2010-06-05 14:45:33.668537657 +0200
  124. +++ b/src/Makefile.in 2010-06-05 14:46:24.936536570 +0200
  125. @@ -1,5 +1,6 @@
  126. CC=@CC@
  127. INSTALL=@INSTALL@
  128. +CFLAGS=@CFLAGS@
  129.  
  130. nvclock_SOURCES=nvclock.c
  131. smartdimmer_SOURCES=smartdimmer.c
  132. @@ -8,9 +9,9 @@
  133. libbackend=./backend/libbackend.a
  134. libnvcontrol=./nvcontrol/libnvcontrol.a
  135.  
  136. -prefix=$(DESTDIR)@prefix@
  137. -exec_prefix=$(DESTDIR)@exec_prefix@
  138. -bindir=$(DESTDIR)@bindir@
  139. +prefix=@prefix@
  140. +exec_prefix=@exec_prefix@
  141. +bindir=@bindir@
  142.  
  143. ifeq ($(HAVE_NVCONTROL), yes)
  144. DEPS=$(libbackend) $(libnvcontrol)
  145. @@ -31,10 +32,10 @@
  146.  
  147.  
  148. nvclock: $(DEPS) $(LIB) nvclock.c
  149. - $(CC) -o nvclock $(nvclock_SOURCES) $(INCLUDES) $(LIBS)
  150. + $(CC) $(CFLAGS) -o nvclock $(nvclock_SOURCES) $(INCLUDES) $(LIBS)
  151.  
  152. smartdimmer: $(DEPS) $(LIB) smartdimmer.c
  153. - $(CC) -o smartdimmer $(smartdimmer_SOURCES) $(INCLUDES) $(LIBS)
  154. + $(CC) $(CFLAGS) -o smartdimmer $(smartdimmer_SOURCES) $(INCLUDES) $(LIBS)
  155.  
  156.  
  157. clean: clean-recursive clean-app
  158. @@ -56,7 +57,8 @@
  159.  
  160. uninstall: uninstall-recursive uninstall-app
  161. uninstall-app:
  162. - rm -f $(bindir)/smartdimmer
  163. + rm -f $(DESTDIR)$(bindir)/nvclock
  164. + rm -f $(DESTDIR)$(bindir)/smartdimmer
  165.  
  166.  
  167. # Walk through the sub directories and do what is requested
  168. Index: b/src/nvcontrol/libnvcontrol.h
  169. ===================================================================
  170. --- a/src/nvcontrol/libnvcontrol.h 2010-06-05 14:45:33.668537657 +0200
  171. +++ b/src/nvcontrol/libnvcontrol.h 2010-06-05 14:46:24.940536861 +0200
  172. @@ -164,7 +164,7 @@
  173. #define NVGetReq(name, req) \
  174. WORD64ALIGN\
  175. if ((dpy->bufptr + SIZEOF(xNV##name##Req)) > dpy->bufmax)\
  176. - _XFlush(dpy);\
  177. + XFlush(dpy);\
  178. req = (xNV##name##Req *)(dpy->last_req = dpy->bufptr);\
  179. req->reqType = dpyinfo->codes->major_opcode;\
  180. req->nvReqType = nv_##name; \
  181. Index: b/src/nvcontrol/Makefile.in
  182. ===================================================================
  183. --- a/src/nvcontrol/Makefile.in 2010-06-05 14:45:33.668537657 +0200
  184. +++ b/src/nvcontrol/Makefile.in 2010-06-05 14:46:24.940536861 +0200
  185. @@ -2,7 +2,8 @@
  186. AR=ar
  187. RANLIB=@RANLIB@
  188. system=@system@
  189. -CFLAGS=@X11_CFLAGS@ -I../backend
  190. +CFLAGS=@CFLAGS@
  191. +CFLAGS+=@X11_CFLAGS@ -I../backend
  192. HAVE_X11=@HAVE_NVCONTROL@
  193. OBJECTS=libnvcontrol.o nvcontrol.o
  194.  
  195. @@ -26,4 +27,4 @@
  196. rm -f Makefile
  197.  
  198. install:
  199. -uninstall:
  200. \ No newline at end of file
  201. +uninstall:
  202. Index: b/src/nvcontrol/libnvcontrol.c
  203. ===================================================================
  204. --- a/src/nvcontrol/libnvcontrol.c 2010-06-05 14:45:33.668537657 +0200
  205. +++ b/src/nvcontrol/libnvcontrol.c 2010-06-05 14:46:24.940536861 +0200
  206. @@ -278,7 +278,7 @@
  207. SyncHandle();
  208. }
  209. /* make sure the attribute is indeed set */
  210. - _XFlush(dpy);
  211. + XFlush(dpy);
  212. }
  213.  
  214. #define X_NVSelectNotify 6
  215. Index: b/src/qt/Makefile.in
  216. ===================================================================
  217. --- a/src/qt/Makefile.in 2010-06-05 14:45:33.668537657 +0200
  218. +++ b/src/qt/Makefile.in 2010-06-05 14:46:24.940536861 +0200
  219. @@ -3,28 +3,27 @@
  220. MOC=@MOC@
  221.  
  222. OBJECTS=main.o qt_nvclock.o qt_nvclock.moc.o qt_xfree.o qt_xfree.moc.o
  223. -CXXFLAGS=@QT_CFLAGS@ -I../backend
  224. +CXXFLAGS=@CXXFLAGS@
  225. +CXXFLAGS+=@QT_CFLAGS@ @X11_CFLAGS@ -I../backend
  226. HAVE_NVCONTROL=@HAVE_NVCONTROL@
  227. HAVE_QT=@HAVE_QT@
  228. libbackend=../backend/libbackend.a
  229.  
  230. -prefix=$(DESTDIR)@prefix@
  231. -exec_prefix=$(DESTDIR)@exec_prefix@
  232. -bindir=$(DESTDIR)@bindir@
  233. +prefix=@prefix@
  234. +exec_prefix=@exec_prefix@
  235. +bindir=@bindir@
  236.  
  237. ifeq ($(HAVE_QT), yes)
  238. PROGRAM=nvclock_qt
  239. - INSTALL_APP=mkdir -p $(bindir); $(INSTALL) -c $(PROGRAM) $(bindir)/$(PROGRAM)
  240. - UNINSTALL_APP=rm -f $(bindir)/$(PROGRAM)
  241. + INSTALL_APP=mkdir -p $(DESTDIR)$(bindir); $(INSTALL) -c $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM)
  242. + UNINSTALL_APP=rm -f $(DESTDIR)$(bindir)/$(PROGRAM)
  243. endif
  244.  
  245. ifeq ($(HAVE_NVCONTROL), yes)
  246. DEPS=$(libbackend) $(libnvcontrol)
  247. - INCLUDES=@X11_CFLAGS@ -I./backend -I./nvcontrol -I.. -I../..
  248. LIBS=@QT_LIBS@ -L../backend -lbackend -L../nvcontrol -lnvcontrol
  249. else
  250. DEPS=$(libbackend)
  251. - INCLUDES=@X11_CFLAGS@ -I./backend -I.. -I../..
  252. LIBS=@QT_LIBS@ -L../backend -lbackend
  253. endif
  254.  
  255. @@ -32,7 +31,7 @@
  256. all: $(PROGRAM)
  257.  
  258. nvclock_qt: $(DEPS) qt_nvclock.moc qt_xfree.moc $(OBJECTS)
  259. - $(CXX) -o nvclock_qt $(CXXFLAGS) $(OBJECTS) $(LIBS)
  260. + $(CXX) $(CXXFLAGS) -o nvclock_qt $(CXXFLAGS) $(OBJECTS) $(LIBS)
  261.  
  262. clean:
  263. rm -f nvclock_qt *.core *.moc *.o
  264. Index: b/src/gtk/Makefile.in
  265. ===================================================================
  266. --- a/src/gtk/Makefile.in 2010-06-05 14:45:33.668537657 +0200
  267. +++ b/src/gtk/Makefile.in 2010-06-05 14:46:24.940536861 +0200
  268. @@ -1,30 +1,29 @@
  269. CC=@CC@
  270. INSTALL=@INSTALL@
  271.  
  272. -CFLAGS=@GTK_CFLAGS@ -I../backend -I../nvcontrol -I../..
  273. +CFLAGS=@CFLAGS@
  274. +CFLAGS+=@GTK_CFLAGS@ @X11_CFLAGS@ -I../backend -I../nvcontrol -I../..
  275. HAVE_GTK2=@HAVE_GTK2@
  276. HAVE_NVCONTROL=@HAVE_NVCONTROL@
  277. libbackend=../backend/libbackend.a
  278. libnvcontrol=../nvcontrol/libnvcontrol.a
  279.  
  280. -prefix=$(DESTDIR)@prefix@
  281. -exec_prefix=$(DESTDIR)@exec_prefix@
  282. -bindir=$(DESTDIR)@bindir@
  283. +prefix=@prefix@
  284. +exec_prefix=@exec_prefix@
  285. +bindir=@bindir@
  286.  
  287. ifeq ($(HAVE_GTK2), yes)
  288. PROGRAM=nvclock_gtk
  289. - INSTALL_APP=mkdir -p $(bindir); $(INSTALL) -c $(PROGRAM) $(bindir)/$(PROGRAM)
  290. - UNINSTALL_APP=rm -f $(bindir)/$(PROGRAM)
  291. + INSTALL_APP=mkdir -p $(DESTDIR)$(bindir); $(INSTALL) -c $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM)
  292. + UNINSTALL_APP=rm -f $(DESTDIR)$(bindir)/$(PROGRAM)
  293. endif
  294.  
  295. ifeq ($(HAVE_NVCONTROL), yes)
  296. DEPS=$(libbackend) $(libnvcontrol)
  297. - INCLUDES=@X11_CFLAGS@ -I./backend -I./nvcontrol -I.. -I../..
  298. LIBS=@GTK_LIBS@ -L../backend -lbackend -L../nvcontrol -lnvcontrol
  299. OBJECTS=banner.o gl.o hw.o main.o settings.o
  300. else
  301. DEPS=$(libbackend)
  302. - INCLUDES=-I./backend -I./nvcontrol -I.. -I../..
  303. LIBS=@GTK_LIBS@ -L../backend -lbackend
  304. OBJECTS=banner.o hw.o main.o settings.o
  305. endif
  306. @@ -34,7 +33,7 @@
  307. all: $(PROGRAM)
  308.  
  309. nvclock_gtk: $(DEPS) $(OBJECTS)
  310. - $(CC) -o nvclock_gtk $(OBJECTS) $(libbackend) $(LIBS)
  311. + $(CC) $(CFLAGS) -o nvclock_gtk $(OBJECTS) $(libbackend) $(LIBS)
  312.  
  313. clean:
  314. rm -f nvclock_gtk *.core *.o *.exe
  315. Index: b/src/gtk/gl.c
  316. ===================================================================
  317. --- a/src/gtk/gl.c 2010-06-05 14:45:33.668537657 +0200
  318. +++ b/src/gtk/gl.c 2010-06-05 14:46:24.940536861 +0200
  319. @@ -146,7 +146,7 @@
  320. if(initialize && conf->save_opengl_changes)
  321. {
  322. NVOptionList *opt = nvcontrol_lookup_option(option);
  323. - char *name;
  324. + char *name = NULL;
  325.  
  326. /* Fsaa/Aniso application control aren't stored in our database,
  327. / so if the requested option can't be found check if it is one
  328. @@ -196,7 +196,7 @@
  329. if(conf->save_opengl_changes)
  330. {
  331. NVOptionList *opt = nvcontrol_lookup_option(option);
  332. - char *name;
  333. + char *name = NULL;
  334.  
  335. /* Fsaa/Aniso application control aren't stored in our database,
  336. / so if the requested option can't be found check if it is one
  337. @@ -395,8 +395,8 @@
  338. GtkWidget *nv_opengl_new(Display* dpy, int screen)
  339. {
  340. NVOpengl *opengl = g_object_new(NV_TYPE_OPENGL, NULL);
  341. - char *glx_vendor, *glx_version, *glx_direct;
  342. - char *gl_vendor, *gl_renderer, *gl_version;
  343. + char *glx_vendor=NULL, *glx_version=NULL, *glx_direct=NULL;
  344. + char *gl_vendor=NULL, *gl_renderer=NULL, *gl_version=NULL;
  345.  
  346. Window win;
  347. Window root;
  348. @@ -441,7 +441,7 @@
  349. {
  350. glx_vendor = (char*)pglXQueryServerString(dpy, screen, GLX_VENDOR);
  351. glx_version = (char*)pglXQueryServerString(dpy, screen, GLX_VERSION);
  352. - glx_direct = (char*)(pglXIsDirect(dpy, ctx) ? "Yes" : "No");
  353. + glx_direct = (pglXIsDirect(dpy, ctx) ? (char*)"Yes" : (char*)"No");
  354. gl_vendor = (char*)pglGetString(GL_VENDOR);
  355. gl_renderer = (char*)pglGetString(GL_RENDERER);
  356. gl_version = (char*)pglGetString(GL_VERSION);
  357. Index: b/src/gtk/hw.c
  358. ===================================================================
  359. --- a/src/gtk/hw.c 2010-06-05 14:45:33.672537694 +0200
  360. +++ b/src/gtk/hw.c 2010-06-05 14:46:24.940536861 +0200
  361. @@ -719,7 +719,6 @@
  362. /* Sets all Nvidia bios info */
  363. void set_bios_info(GtkWidget *widget)
  364. {
  365. - char *tmp;
  366. int i;
  367. NVBios *bios = NV_BIOS(widget);
  368. GtkTreeIter iter;
  369. @@ -943,7 +942,7 @@
  370. {
  371. desc = g_strdup_printf("-");
  372. masked = g_strdup_printf("-");
  373. - state = g_strdup_printf("");
  374. + state = g_strdup_printf("Unknown");
  375. }
  376.  
  377. if((i >= 8) && (mask & 1<<i))
  378. @@ -963,7 +962,7 @@
  379. {
  380. desc = g_strdup_printf("-");
  381. masked = g_strdup_printf("-");
  382. - state = g_strdup_printf("");
  383. + state = g_strdup_printf("Unknown");
  384. }
  385. gtk_tree_store_append(pipeline->store, &iter, NULL);
  386. gtk_tree_store_set(pipeline->store, &iter,
  387. @@ -1623,7 +1622,6 @@
  388. {
  389. NVThermal *thermal = g_object_new(NV_TYPE_THERMAL, NULL);
  390. GtkWidget *hbox;
  391. - int have_ambient;
  392.  
  393. thermal->card = card;
  394. thermal->conf = conf;
  395. @@ -1748,7 +1746,6 @@
  396. /* If opengl stuff isn't supported don't show it on the gui */
  397. if(init_nvcontrol(dpy))
  398. {
  399. - int tmp;
  400. NVGetAttribute(dpy, 0, 0, NV_IRQ, &irq);
  401. }
  402. #else
  403. Index: b/src/gtk/main.c
  404. ===================================================================
  405. --- a/src/gtk/main.c 2010-06-05 14:45:33.672537694 +0200
  406. +++ b/src/gtk/main.c 2010-06-05 14:46:24.940536861 +0200
  407. @@ -25,6 +25,7 @@
  408.  
  409. #include <stdlib.h>
  410. #include <gtk/gtk.h>
  411. +#include <X11/Xlib.h>
  412.  
  413. #include "banner.h"
  414. #include "interface.h"
  415. Index: b/src/smartdimmer.c
  416. ===================================================================
  417. --- a/src/smartdimmer.c 2010-06-05 14:45:33.700536566 +0200
  418. +++ b/src/smartdimmer.c 2010-06-05 14:46:24.940536861 +0200
  419. @@ -35,6 +35,7 @@
  420. * Erik Waling <erikw@acc.umu.se> *
  421. ******************************************************************************/
  422.  
  423. +#include <ctype.h>
  424. #include <stdio.h>
  425. #include <stdlib.h>
  426. #include <getopt.h>
  427. Index: b/src/backend/utils.c
  428. ===================================================================
  429. --- a/src/backend/utils.c 2010-06-05 14:45:33.704537660 +0200
  430. +++ b/src/backend/utils.c 2010-06-05 14:46:24.940536861 +0200
  431. @@ -20,6 +20,7 @@
  432. */
  433.  
  434. #include <stdio.h>
  435. +#include "nvclock.h"
  436.  
  437. /* Convert the gpu architecture to a string using NVxx/Gxx naming */
  438. int convert_gpu_architecture(short arch, char *buf)
  439. @@ -78,3 +79,163 @@
  440. }
  441. buf[len] = 0;
  442. }
  443. +
  444. +/* Internal gpu architecture function which sets
  445. +/ a device to a specific architecture. This architecture
  446. +/ doesn't have to be the real architecture. It is mainly
  447. +/ used to choose codepaths inside nvclock.
  448. +*/
  449. +int get_gpu_arch(int device_id)
  450. +{
  451. + int arch;
  452. + switch(device_id & 0xff0)
  453. + {
  454. + case 0x20:
  455. + arch = NV5;
  456. + break;
  457. + case 0x100:
  458. + case 0x110:
  459. + case 0x150:
  460. + case 0x1a0:
  461. + arch = NV10;
  462. + break;
  463. + case 0x170:
  464. + case 0x180:
  465. + case 0x1f0:
  466. + arch = NV17;
  467. + break;
  468. + case 0x200:
  469. + arch = NV20;
  470. + break;
  471. + case 0x250:
  472. + case 0x280:
  473. + case 0x320: /* We don't treat the FX5200/FX5500 as FX cards */
  474. + arch = NV25;
  475. + break;
  476. + case 0x300:
  477. + arch = NV30;
  478. + break;
  479. + case 0x330:
  480. + arch = NV35; /* Similar to NV30 but fanspeed stuff works differently */
  481. + break;
  482. + /* Give a seperate arch to FX5600/FX5700 cards as they need different code than other FX cards */
  483. + case 0x310:
  484. + case 0x340:
  485. + arch = NV31;
  486. + break;
  487. + case 0x40:
  488. + case 0x120:
  489. + case 0x130:
  490. + case 0x210:
  491. + case 0x230:
  492. + arch = NV40;
  493. + break;
  494. + case 0xc0:
  495. + arch = NV41;
  496. + break;
  497. + case 0x140:
  498. + arch = NV43; /* Similar to NV40 but with different fanspeed code */
  499. + break;
  500. + case 0x160:
  501. + case 0x220:
  502. + arch = NV44;
  503. + break;
  504. + case 0x1d0:
  505. + arch = NV46;
  506. + break;
  507. + case 0x90:
  508. + arch = NV47;
  509. + break;
  510. + case 0x290:
  511. + arch = NV49; /* 7900 */
  512. + break;
  513. + case 0x390:
  514. + arch = NV4B; /* 7600 */
  515. + break;
  516. + case 0x190:
  517. + arch = NV50; /* 8800 'NV50 / G80' */
  518. + break;
  519. + case 0x400: /* 8600 'G84' */
  520. + arch = G84;
  521. + break;
  522. + case 0x420: /* 8500 'G86' */
  523. + arch = G86;
  524. + break;
  525. + case 0x5e0: /* GT2x0 */
  526. + case 0x5f0: /* GT2x0 */
  527. + arch = GT200;
  528. + break;
  529. + case 0x6e0: /* G98 */
  530. + case 0x6f0: /* G98 */
  531. + case 0x840: /* C7x */
  532. + case 0x850: /* C7x */
  533. + case 0x860: /* C79 */
  534. + case 0x870: /* C7x */
  535. + arch = G86;
  536. + break;
  537. + case 0x600: /* G92 */
  538. + case 0x610: /* G92 */
  539. + arch = G92;
  540. + break;
  541. + case 0x620: /* 9600GT 'G94' */
  542. + arch = G94;
  543. + break;
  544. + case 0x640: /* 9500GT */
  545. + arch = G96;
  546. + break;
  547. + case 0x240:
  548. + case 0x3d0: /* not sure if this is a C51 too */
  549. + case 0x530: /* not sure if the 70xx is C51 too */
  550. + arch = C51;
  551. + break;
  552. + case 0x2e0:
  553. + case 0xf0:
  554. + /* The code above doesn't work for pci-express cards as multiple architectures share one id-range */
  555. + switch(device_id)
  556. + {
  557. + case 0xf0: /* 6800 */
  558. + case 0xf9: /* 6800Ultra */
  559. + arch = NV40;
  560. + break;
  561. + case 0xf6: /* 6800GS/XT */
  562. + arch = NV41;
  563. + break;
  564. + case 0xf1: /* 6600/6600GT */
  565. + case 0xf2: /* 6600GT */
  566. + case 0xf3: /* 6200 */
  567. + case 0xf4: /* 6600LE */
  568. + arch = NV43;
  569. + break;
  570. + case 0xf5: /* 7800GS */
  571. + arch = NV47;
  572. + break;
  573. + case 0xfa: /* PCX5700 */
  574. + arch = NV31;
  575. + break;
  576. + case 0xf8: /* QuadroFX 3400 */
  577. + case 0xfb: /* PCX5900 */
  578. + arch = NV35;
  579. + break;
  580. + case 0xfc: /* PCX5300 */
  581. + case 0xfd: /* Quadro NVS280/FX330, FX5200 based? */
  582. + case 0xff: /* PCX4300 */
  583. + arch = NV25;
  584. + break;
  585. + case 0xfe: /* Quadro 1300, has the same id as a FX3000 */
  586. + arch = NV35;
  587. + break;
  588. + case 0x2e0: /* Geforce 7600GT AGP (at least Leadtek uses this id) */
  589. + case 0x2e1: /* Geforce 7600GS AGP (at least BFG uses this id) */
  590. + case 0x2e2: /* Geforce 7300GT AGP (at least a Galaxy 7300GT uses this id) */
  591. + arch = NV4B;
  592. + break;
  593. + case 0x2e4: /* Geforce 7950 GT AGP */
  594. + arch = NV49;
  595. + break;
  596. + }
  597. + break;
  598. + default:
  599. + arch = UNKNOWN;
  600. + }
  601. + return arch;
  602. +}
  603. Index: b/src/backend/Makefile.in
  604. ===================================================================
  605. --- a/src/backend/Makefile.in 2010-06-05 14:45:33.704537660 +0200
  606. +++ b/src/backend/Makefile.in 2010-06-05 14:46:24.940536861 +0200
  607. @@ -11,9 +11,13 @@
  608. OBJECTS+=back_bsd.o
  609. else
  610. ifeq ($(system), Win32)
  611. - OBJECTS+=back_win32.o
  612. + OBJECTS+=back_win32.o
  613. else
  614. - OBJECTS+=back_linux.o
  615. + ifeq ($(system), SunOS)
  616. + OBJECTS+=back_solaris.o
  617. + else
  618. + OBJECTS+=back_linux.o
  619. + endif
  620. endif
  621. endif
  622.  
  623. Index: b/src/backend/config.c
  624. ===================================================================
  625. --- a/src/backend/config.c 2010-06-05 14:45:33.704537660 +0200
  626. +++ b/src/backend/config.c 2010-06-05 14:46:24.940536861 +0200
  627. @@ -319,6 +319,11 @@
  628. cfg_entry *pCfg = NULL;
  629.  
  630. pCfg = cfg;
  631. + if(!fp)
  632. + {
  633. + fprintf(stderr, "Unable to write configuration file to '%s'. Do you have sufficient permissions?\n", file);
  634. + return;
  635. + }
  636.  
  637. fprintf(fp, "#This is NVClock's config file. Don't edit the hw and general section!\n");
  638. while(pCfg != NULL)
  639. Index: b/src/backend/nvreg.h
  640. ===================================================================
  641. --- a/src/backend/nvreg.h 2010-06-05 14:45:33.704537660 +0200
  642. +++ b/src/backend/nvreg.h 2010-06-05 14:46:24.940536861 +0200
  643. @@ -26,6 +26,7 @@
  644. # define PCI_VENDOR_ID_SANYO 0x144d /* Samsung laptops use the Sanyo vendor id */
  645. # define PCI_VENDOR_ID_SONY 0x104d
  646. # define PCI_VENDOR_ID_ZEPTO 0x1a46
  647. +# define PCI_VENDOR_ID_NVIDIA 0x10de
  648. #define PCI_DEVICE_ID 0x2 /* 16-bit */
  649. #define PCI_SUBSYSTEM_VENDOR_ID 0x2c /* 16-bit */
  650. #define PCI_SUBSYSTEM_ID 0x2e /* 16-bit */
  651. @@ -58,6 +59,7 @@
  652. #define PCIE_LINKSTATUS 0x12
  653. # define PCIE_LINK_SPEED_MASK 0x3f0
  654. # define PCIE_LINK_SPEED_SHIFT 4
  655. +#define PCI_CLASS_VGA 0x3
  656.  
  657. /* PMC */
  658. #define NV_PMC_BOOT_0 0x0
  659. Index: b/src/backend/nv40.c
  660. ===================================================================
  661. --- a/src/backend/nv40.c 2010-06-05 14:45:33.704537660 +0200
  662. +++ b/src/backend/nv40.c 2010-06-05 14:46:24.940536861 +0200
  663. @@ -68,6 +68,7 @@
  664.  
  665. #include <stdio.h>
  666. #include <string.h>
  667. +#include <unistd.h>
  668. #include "backend.h"
  669.  
  670. /*
  671. Index: b/src/backend/backend.c
  672. ===================================================================
  673. --- a/src/backend/backend.c 2010-06-05 14:45:33.704537660 +0200
  674. +++ b/src/backend/backend.c 2010-06-05 14:46:24.940536861 +0200
  675. @@ -1,6 +1,6 @@
  676. /* NVClock 0.8 - Linux overclocker for NVIDIA cards
  677. *
  678. - * Copyright(C) 2001-2007 Roderick Colenbrander
  679. + * Copyright(C) 2001-2009 Roderick Colenbrander
  680. *
  681. * site: http://nvclock.sourceforge.net
  682. *
  683. @@ -29,6 +29,48 @@
  684. #endif
  685. #include "backend.h"
  686.  
  687. +int map_mem(const char *dev_name)
  688. +{
  689. + dev_handle_t *fd = open_dev(dev_name);
  690. +
  691. + if(!fd) /* open_dev has already set the error */
  692. + return 0;
  693. +
  694. + /* Map the registers of the nVidia chip */
  695. + nv_card->PEXTDEV = map_dev_mem(fd, nv_card->reg_address + 0x101000, 0x1000);
  696. + nv_card->PFB = map_dev_mem(fd, nv_card->reg_address + 0x100000, 0x1000);
  697. + /* normally pmc is till 0x2000 but extended it for nv40 */
  698. + nv_card->PMC = map_dev_mem(fd, nv_card->reg_address + 0x000000, 0x2ffff);
  699. + nv_card->PCIO = map_dev_mem(fd, nv_card->reg_address + 0x601000, 0x2000);
  700. + nv_card->PDISPLAY = map_dev_mem(fd, nv_card->reg_address + NV_PDISPLAY_OFFSET, NV_PDISPLAY_SIZE);
  701. + nv_card->PRAMDAC = map_dev_mem(fd, nv_card->reg_address + 0x680000, 0x2000);
  702. + nv_card->PRAMIN = map_dev_mem(fd, nv_card->reg_address + NV_PRAMIN_OFFSET, NV_PRAMIN_SIZE);
  703. + nv_card->PROM = map_dev_mem(fd, nv_card->reg_address + 0x300000, 0xffff);
  704. +
  705. + /* On Geforce 8xxx cards it appears that the pci config header has been moved */
  706. + if(nv_card->arch & NV5X)
  707. + nv_card->PBUS = map_dev_mem(fd, nv_card->reg_address + 0x88000, 0x100);
  708. + else
  709. + nv_card->PBUS = nv_card->PMC + 0x1800/4;
  710. +
  711. + nv_card->mem_mapped = 1;
  712. +
  713. + close_dev(fd);
  714. + return 1;
  715. +}
  716. +
  717. +void unmap_mem()
  718. +{
  719. + unmap_dev_mem((unsigned long)nv_card->PEXTDEV, 0x1000);
  720. + unmap_dev_mem((unsigned long)nv_card->PFB, 0x1000);
  721. + unmap_dev_mem((unsigned long)nv_card->PMC, 0x2ffff);
  722. + unmap_dev_mem((unsigned long)nv_card->PCIO, 0x2000);
  723. + unmap_dev_mem((unsigned long)nv_card->PDISPLAY, NV_PDISPLAY_SIZE);
  724. + unmap_dev_mem((unsigned long)nv_card->PRAMDAC, 0x2000);
  725. + unmap_dev_mem((unsigned long)nv_card->PRAMIN, NV_PRAMIN_SIZE);
  726. + unmap_dev_mem((unsigned long)nv_card->PROM, 0xffff);
  727. +}
  728. +
  729. /* Read a byte from the pci bus */
  730. unsigned char nv_read_pbus8(int offset)
  731. {
  732. Index: b/src/backend/back_bsd.c
  733. ===================================================================
  734. --- a/src/backend/back_bsd.c 2010-06-05 14:45:33.708537666 +0200
  735. +++ b/src/backend/back_bsd.c 2010-06-05 14:46:24.940536861 +0200
  736. @@ -2,7 +2,7 @@
  737. *
  738. * Site: http://nvclock.sourceforge.net
  739. *
  740. - * Copyright(C) 2001-2005 Roderick Colenbrander
  741. + * Copyright(C) 2001-2009 Roderick Colenbrander
  742. * Portions Copyright(C) 2003 Samy Al Bahra <samy@kerneled.com>
  743. *
  744. * This program is free software; you can redistribute it and/or modify
  745. @@ -41,8 +41,6 @@
  746. # include <sys/pciio.h>
  747. #endif
  748.  
  749. -#define NV_VENDOR 0x10de
  750. -#define VGA 0x03
  751. #define SIZE 255
  752.  
  753. NVClock nvclock;
  754. @@ -90,8 +88,8 @@
  755.  
  756. memset(&pcidev,0,sizeof(pcidev));
  757. pcidev.pat_buf_len=sizeof(patterns);
  758. - patterns.pc_vendor=NV_VENDOR;
  759. - patterns.pc_class=VGA;
  760. + patterns.pc_vendor=PCI_VENDOR_ID_NVIDIA;
  761. + patterns.pc_class=PCI_CLASS_VGA;
  762. patterns.flags=PCI_GETCONF_MATCH_VENDOR|PCI_GETCONF_MATCH_CLASS;
  763. pcidev.patterns=&patterns;
  764. pcidev.num_patterns=1;
  765. @@ -183,8 +181,10 @@
  766. return pi.pi_data;
  767. }
  768.  
  769. -int map_mem(const char *dev_name)
  770. +/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
  771. +dev_handle_t* open_dev(const char *dev_name)
  772. {
  773. + dev_handle_t *dev;
  774. int fd;
  775.  
  776. if( (fd = open(dev_name, O_RDWR)) == -1 )
  777. @@ -192,48 +192,29 @@
  778. char err[80];
  779. sprintf(err, "Can't open %s", dev_name);
  780. set_error_str(err);
  781. - return 0;
  782. + return NULL;
  783. }
  784. -
  785. - /* Map the registers of the nVidia chip */
  786. - nv_card->PEXTDEV = map_dev_mem(fd, nv_card->reg_address + 0x101000, 0x1000);
  787. - nv_card->PFB = map_dev_mem(fd, nv_card->reg_address + 0x100000, 0x1000);
  788. - /* normally pmc is till 0x2000 but extended it for nv40 */
  789. - nv_card->PMC = map_dev_mem(fd, nv_card->reg_address + 0x000000, 0x2ffff);
  790. - nv_card->PCIO = map_dev_mem(fd, nv_card->reg_address + 0x601000, 0x2000);
  791. - nv_card->PDISPLAY = map_dev_mem(fd, nv_card->reg_address + NV_PDISPLAY_OFFSET, NV_PDISPLAY_SIZE);
  792. - nv_card->PRAMDAC = map_dev_mem(fd, nv_card->reg_address + 0x680000, 0x2000);
  793. - nv_card->PRAMIN = map_dev_mem(fd, nv_card->reg_address + NV_PRAMIN_OFFSET, NV_PRAMIN_SIZE);
  794. - nv_card->PROM = map_dev_mem(fd, nv_card->reg_address + 0x300000, 0xffff);
  795. -
  796. - /* On Geforce 8xxx cards it appears that the pci config header has been moved */
  797. - if(nv_card->arch & NV5X)
  798. - nv_card->PBUS = map_dev_mem(fd, nv_card->reg_address + 0x88000, 0x100);
  799. - else
  800. - nv_card->PBUS = nv_card->PMC + 0x1800/4;
  801.  
  802. - nv_card->mem_mapped = 1;
  803. - close(fd);
  804. - return 1;
  805. + dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
  806. + dev->fd = fd;
  807. + return dev;
  808. }
  809.  
  810. -void unmap_mem()
  811. +/* Close the devide handle */
  812. +void close_dev(dev_handle_t *dev)
  813. {
  814. - unmap_dev_mem((unsigned long)nv_card->PEXTDEV, 0x1000);
  815. - unmap_dev_mem((unsigned long)nv_card->PFB, 0x1000);
  816. - unmap_dev_mem((unsigned long)nv_card->PMC, 0xffff);
  817. - unmap_dev_mem((unsigned long)nv_card->PCIO, 0x2000);
  818. - unmap_dev_mem((unsigned long)nv_card->PDISPLAY, NV_PDISPLAY_SIZE);
  819. - unmap_dev_mem((unsigned long)nv_card->PRAMDAC, 0x2000);
  820. - unmap_dev_mem((unsigned long)nv_card->PRAMIN, NV_PRAMIN_SIZE);
  821. - unmap_dev_mem((unsigned long)nv_card->PROM, 0xffff);
  822. + if(!dev)
  823. + return;
  824. +
  825. + close(dev->fd);
  826. + free(dev);
  827. }
  828.  
  829. /* -------- mmap on devices -------- */
  830. /* This piece of code is from nvtv a linux program for tvout */
  831. /* The author of nvtv got this from xfree86's os-support/linux/lnx_video.c */
  832. /* and he modified it a little */
  833. -static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size)
  834. +void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size)
  835. {
  836. void *base;
  837. int mapflags = MAP_SHARED;
  838. @@ -243,10 +224,11 @@
  839. alignOff = Base - realBase;
  840.  
  841. base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE,
  842. - mapflags, fd, (off_t)realBase);
  843. + mapflags, dev->fd, (off_t)realBase);
  844. return (void *) ((char *)base + alignOff);
  845. }
  846.  
  847. +
  848. static void unmap_dev_mem (unsigned long Base, unsigned long Size)
  849. {
  850. unsigned long alignOff = Base - (Base & ~(getpagesize() - 1));
  851. Index: b/src/backend/info.c
  852. ===================================================================
  853. --- a/src/backend/info.c 2010-06-05 14:45:33.708537666 +0200
  854. +++ b/src/backend/info.c 2010-06-05 14:46:24.944536740 +0200
  855. @@ -334,6 +334,7 @@
  856. { 0x5e0, "nvidia GeForce GT200-400", DESKTOP },
  857. { 0x5e1, "nvidia GeForce GTX 280", DESKTOP },
  858. { 0x5e2, "nvidia GeForce GTX 260", DESKTOP },
  859. + { 0x5e3, "nvidia GeForce GTX 285", DESKTOP },
  860. { 0x5e7, "nvidia Tesla C1060", DESKTOP },
  861. { 0x5ed, "nvidia Quadroplex 2200 D2", DESKTOP },
  862. { 0x5f8, "nvidia Quadroplex 2200 S4", DESKTOP },
  863. @@ -351,11 +352,13 @@
  864. { 0x611, "nVidia Geforce 8800GT", DESKTOP },
  865. { 0x612, "nVidia Geforce 9800GTX", DESKTOP },
  866. { 0x614, "nVidia Geforce 9800GT", DESKTOP },
  867. + { 0x615, "nVidia GeForce GTS 250", DESKTOP },
  868. { 0x61a, "nVidia QuadroFX 3700", DESKTOP },
  869. { 0x61c, "nVidia QuadroFX 3600M", MOBILE },
  870. { 0x622, "nVidia Geforce 9600GT", DESKTOP },
  871. { 0x623, "nVidia Geforce 9600GS", DESKTOP },
  872. { 0x640, "nVidia Geforce 9500GT", DESKTOP },
  873. + { 0x641, "nVidia Geforce 9400GT", DESKTOP },
  874. { 0x643, "nVidia Geforce 9500GT", DESKTOP },
  875. { 0x647, "nVidia Geforce 9600M GT", MOBILE },
  876. { 0x648, "nVidia Geforce 9600M GS", MOBILE },
  877. @@ -398,6 +401,15 @@
  878. { 0x863, "nVidia Geforce 9400M", MOBILE },
  879. { 0x864, "nVidia Geforce 9300", DESKTOP },
  880. { 0x865, "nVidia Geforce 9300", DESKTOP },
  881. + { 0x870, "NVIDIA GeForce 9400M", MOBILE },
  882. + { 0x871, "NVIDIA GeForce 9200", MOBILE },
  883. + { 0x872, "NVIDIA GeForce G102M", MOBILE },
  884. + { 0x873, "NVIDIA GeForce G102M", MOBILE },
  885. + { 0x874, "NVIDIA ION", NFORCE },
  886. + { 0x876, "NVIDIA ION", NFORCE },
  887. + { 0x87a, "NVIDIA Quadro FX 470", MOBILE },
  888. + { 0x87d, "NVIDIA ION", NFORCE },
  889. + { 0x87f, "NVIDIA MCP79", NFORCE },
  890. { 0, NULL, UNKNOWN }
  891. };
  892.  
  893. @@ -421,163 +433,6 @@
  894. return "Unknown Nvidia card";
  895. }
  896.  
  897. -/* Internal gpu architecture function which sets
  898. -/ a device to a specific architecture. This architecture
  899. -/ doesn't have to be the real architecture. It is mainly
  900. -/ used to choose codepaths inside nvclock.
  901. -*/
  902. -int get_gpu_arch(int device_id)
  903. -{
  904. - int arch;
  905. - switch(device_id & 0xff0)
  906. - {
  907. - case 0x20:
  908. - arch = NV5;
  909. - break;
  910. - case 0x100:
  911. - case 0x110:
  912. - case 0x150:
  913. - case 0x1a0:
  914. - arch = NV10;
  915. - break;
  916. - case 0x170:
  917. - case 0x180:
  918. - case 0x1f0:
  919. - arch = NV17;
  920. - break;
  921. - case 0x200:
  922. - arch = NV20;
  923. - break;
  924. - case 0x250:
  925. - case 0x280:
  926. - case 0x320: /* We don't treat the FX5200/FX5500 as FX cards */
  927. - arch = NV25;
  928. - break;
  929. - case 0x300:
  930. - arch = NV30;
  931. - break;
  932. - case 0x330:
  933. - arch = NV35; /* Similar to NV30 but fanspeed stuff works differently */
  934. - break;
  935. - /* Give a seperate arch to FX5600/FX5700 cards as they need different code than other FX cards */
  936. - case 0x310:
  937. - case 0x340:
  938. - arch = NV31;
  939. - break;
  940. - case 0x40:
  941. - case 0x120:
  942. - case 0x130:
  943. - case 0x210:
  944. - case 0x230:
  945. - arch = NV40;
  946. - break;
  947. - case 0xc0:
  948. - arch = NV41;
  949. - break;
  950. - case 0x140:
  951. - arch = NV43; /* Similar to NV40 but with different fanspeed code */
  952. - break;
  953. - case 0x160:
  954. - case 0x220:
  955. - arch = NV44;
  956. - break;
  957. - case 0x1d0:
  958. - arch = NV46;
  959. - break;
  960. - case 0x90:
  961. - arch = NV47;
  962. - break;
  963. - case 0x290:
  964. - arch = NV49; /* 7900 */
  965. - break;
  966. - case 0x390:
  967. - arch = NV4B; /* 7600 */
  968. - break;
  969. - case 0x190:
  970. - arch = NV50; /* 8800 'NV50 / G80' */
  971. - break;
  972. - case 0x400: /* 8600 'G84' */
  973. - arch = G84;
  974. - break;
  975. - case 0x420: /* 8500 'G86' */
  976. - arch = G86;
  977. - break;
  978. - case 0x5e0: /* GT2x0 */
  979. - case 0x5f0: /* GT2x0 */
  980. - arch = GT200;
  981. - break;
  982. - case 0x6e0: /* G98 */
  983. - case 0x6f0: /* G98 */
  984. - case 0x860: /* C79 */
  985. - arch = G86;
  986. - break;
  987. - case 0x600: /* G92 */
  988. - case 0x610: /* G92 */
  989. - arch = G92;
  990. - break;
  991. - case 0x620: /* 9600GT 'G94' */
  992. - arch = G94;
  993. - break;
  994. - case 0x640: /* 9500GT */
  995. - arch = G96;
  996. - break;
  997. - case 0x240:
  998. - case 0x3d0: /* not sure if this is a C51 too */
  999. - case 0x530: /* not sure if the 70xx is C51 too */
  1000. - arch = C51;
  1001. - break;
  1002. - case 0x2e0:
  1003. - case 0xf0:
  1004. - /* The code above doesn't work for pci-express cards as multiple architectures share one id-range */
  1005. - switch(device_id)
  1006. - {
  1007. - case 0xf0: /* 6800 */
  1008. - case 0xf9: /* 6800Ultra */
  1009. - arch = NV40;
  1010. - break;
  1011. - case 0xf6: /* 6800GS/XT */
  1012. - arch = NV41;
  1013. - break;
  1014. - case 0xf1: /* 6600/6600GT */
  1015. - case 0xf2: /* 6600GT */
  1016. - case 0xf3: /* 6200 */
  1017. - case 0xf4: /* 6600LE */
  1018. - arch = NV43;
  1019. - break;
  1020. - case 0xf5: /* 7800GS */
  1021. - arch = NV47;
  1022. - break;
  1023. - case 0xfa: /* PCX5700 */
  1024. - arch = NV31;
  1025. - break;
  1026. - case 0xf8: /* QuadroFX 3400 */
  1027. - case 0xfb: /* PCX5900 */
  1028. - arch = NV35;
  1029. - break;
  1030. - case 0xfc: /* PCX5300 */
  1031. - case 0xfd: /* Quadro NVS280/FX330, FX5200 based? */
  1032. - case 0xff: /* PCX4300 */
  1033. - arch = NV25;
  1034. - break;
  1035. - case 0xfe: /* Quadro 1300, has the same id as a FX3000 */
  1036. - arch = NV35;
  1037. - break;
  1038. - case 0x2e0: /* Geforce 7600GT AGP (at least Leadtek uses this id) */
  1039. - case 0x2e1: /* Geforce 7600GS AGP (at least BFG uses this id) */
  1040. - case 0x2e2: /* Geforce 7300GT AGP (at least a Galaxy 7300GT uses this id) */
  1041. - arch = NV4B;
  1042. - break;
  1043. - case 0x2e4: /* Geforce 7950 GT AGP */
  1044. - arch = NV49;
  1045. - break;
  1046. - }
  1047. - break;
  1048. - default:
  1049. - arch = UNKNOWN;
  1050. - }
  1051. - return arch;
  1052. -}
  1053. -
  1054. /* Receive the real gpu architecture */
  1055. static short get_gpu_architecture()
  1056. {
  1057. Index: b/src/backend/back_solaris.c
  1058. ===================================================================
  1059. --- /dev/null 1970-01-01 00:00:00.000000000 +0000
  1060. +++ b/src/backend/back_solaris.c 2010-06-05 14:46:24.944536740 +0200
  1061. @@ -0,0 +1,205 @@
  1062. +/* NVClock 0.8 - OpenSolaris overclocker for NVIDIA cards
  1063. + *
  1064. + * Site: http://nvclock.sourceforge.net
  1065. + *
  1066. + * Solaris Backend: Copyright 2009 Bernd Markgraf <markgraf@med.ovgu.de>
  1067. + * Copyright(C) 2001-2009 Roderick Colenbrander
  1068. + *
  1069. + * This program is free software; you can redistribute it and/or modify
  1070. + * it under the terms of the GNU General Public License as published by
  1071. + * the Free Software Foundation; either version 2 of the License, or
  1072. + * (at your option) any later version.
  1073. + *
  1074. + * This program is distributed in the hope that it will be useful,
  1075. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1076. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1077. + * GNU General Public License for more details.
  1078. + *
  1079. + * You should have received a copy of the GNU General Public License
  1080. + * along with this program; if not, write to the Free Software
  1081. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  1082. + */
  1083. +
  1084. +#include <errno.h>
  1085. +#include <fcntl.h>
  1086. +#include <stdio.h>
  1087. +#include <stdlib.h>
  1088. +#include <stdint.h>
  1089. +#include <string.h>
  1090. +#include <sys/types.h>
  1091. +#include <sys/ioctl.h>
  1092. +#include <sys/param.h>
  1093. +#include <sys/mman.h>
  1094. +#include <pciaccess.h>
  1095. +#include <sys/pci.h>
  1096. +
  1097. +#include "backend.h"
  1098. +
  1099. +#define SIZE 255
  1100. +#define DEBUG 0
  1101. +
  1102. +NVClock nvclock;
  1103. +NVCard *nv_card = NULL;
  1104. +
  1105. +static int probe_devices();
  1106. +
  1107. +int init_nvclock()
  1108. +{
  1109. + /* Check if the user is root */
  1110. + if(getuid() != 0 && geteuid() != 0)
  1111. + {
  1112. + set_error(NV_ERR_NOT_ENOUGH_PERMISSIONS);
  1113. + return 0;
  1114. + }
  1115. +
  1116. + /* Detect all nvidia cards; this needs to be done before creating directory and config file as that code needs card access */
  1117. + if(!probe_devices())
  1118. + {
  1119. + /* probe_devices takes care of the error as it isn't certain it failed because of there are no nvidia cards */
  1120. + return 0;
  1121. + }
  1122. +
  1123. + if(!open_config())
  1124. + return 0;
  1125. +
  1126. + return 1;
  1127. +}
  1128. +
  1129. +static int probe_devices()
  1130. +{
  1131. + struct pci_device *pcidev;
  1132. + struct pci_id_match *patterns;
  1133. + struct pci_device_iterator *iter;
  1134. +
  1135. + int counter=0;
  1136. +
  1137. + pcidev=calloc(1, sizeof(struct pci_device));
  1138. + patterns=calloc(1,sizeof(struct pci_id_match));
  1139. +
  1140. + patterns->vendor_id=PCI_VENDOR_ID_NVIDIA;
  1141. + patterns->device_class=PCI_CLASS_VGA<<16;
  1142. + patterns->device_id=PCI_MATCH_ANY;
  1143. + patterns->subdevice_id=PCI_MATCH_ANY;
  1144. + patterns->subvendor_id=PCI_MATCH_ANY;
  1145. + patterns->device_class_mask=PCI_MATCH_ANY;
  1146. +
  1147. + pci_system_init();
  1148. + iter = pci_id_match_iterator_create(patterns);
  1149. + while (( pcidev = pci_device_next( iter )) != NULL )
  1150. + {
  1151. +#if DEBUG
  1152. + printf("count %d, vend 0x%x, dev 0x%x, class 0x%x\n",counter,pcidev->vendor_id,pcidev->device_id,pcidev->device_class>>16);
  1153. +#endif
  1154. + nvclock.card[counter].device_id=pcidev->device_id;
  1155. + nvclock.card[counter].dev_name= "/dev/xsvc";
  1156. + nvclock.card[counter].card_name = (char*)get_card_name(nvclock.card[counter].device_id, &nvclock.card[counter].gpu);
  1157. + nvclock.card[counter].arch = get_gpu_arch(nvclock.card[counter].device_id);
  1158. + nvclock.card[counter].number = counter;
  1159. + nvclock.card[counter].state = 0;
  1160. + nvclock.card[counter].devbusfn = PCI_GET_DEVBUSFN(pcidev->dev, pcidev->bus, pcidev->func);
  1161. + pci_device_probe( pcidev );
  1162. +#if DEBUG
  1163. + int i;
  1164. + for ( i = 0 ; i < 6 ; i++ )
  1165. + {
  1166. + if ( pcidev->regions[i].base_addr != 0 )
  1167. + {
  1168. + printf( " BASE%u 0x%08x addr 0x%08x %s",
  1169. + i,
  1170. + 0,
  1171. + (intptr_t) pcidev->regions[i].base_addr,
  1172. + (pcidev->regions[i].is_IO) ? "I/O" : "MEM" );
  1173. +
  1174. + if ( ! pcidev->regions[i].is_IO )
  1175. + {
  1176. + if ( pcidev->regions[i].is_prefetchable )
  1177. + {
  1178. + printf( " PREFETCHABLE" );
  1179. + }
  1180. + }
  1181. +
  1182. + printf( "\n" );
  1183. + }
  1184. + }
  1185. +#endif
  1186. + nvclock.card[counter].reg_address=pcidev->regions[0].base_addr;
  1187. + counter++;
  1188. + }
  1189. +
  1190. + nvclock.num_cards = counter;
  1191. +
  1192. + pci_system_cleanup();
  1193. +
  1194. + return 1;
  1195. +}
  1196. +
  1197. +int32_t pciReadLong(unsigned short devbusfn, long offset)
  1198. +{
  1199. + struct pci_device *pcidev;
  1200. + int32_t data;
  1201. +
  1202. + pci_system_init();
  1203. + pcidev=pci_device_find_by_slot(0,PCI_GET_BUS(devbusfn),PCI_GET_DEVICE(devbusfn),PCI_GET_FUNCTION(devbusfn));
  1204. +#if DEBUG
  1205. + printf("pciReadLong vend 0x%x, dev 0x%x, class 0x%x\n",pcidev->vendor_id,pcidev->device_id,pcidev->device_class>>16);
  1206. +#endif
  1207. +
  1208. + pci_device_cfg_read_u32(pcidev,&data,offset);
  1209. +
  1210. + pci_system_cleanup();
  1211. + return data;
  1212. +}
  1213. +
  1214. +
  1215. +/* -------- mmap on devices -------- */
  1216. +/* This piece of code is from nvtv a linux program for tvout */
  1217. +/* The author of nvtv got this from xfree86's os-support/linux/lnx_video.c */
  1218. +/* and he modified it a little */
  1219. +void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size)
  1220. +{
  1221. + void *base;
  1222. + int mapflags = MAP_SHARED;
  1223. + unsigned long realBase, alignOff;
  1224. +
  1225. + realBase = Base & ~(getpagesize() - 1);
  1226. + alignOff = Base - realBase;
  1227. +
  1228. + base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE, mapflags, dev->fd, (off_t)realBase);
  1229. + return (void *) ((char *)base + alignOff);
  1230. +}
  1231. +
  1232. +void unmap_dev_mem (unsigned long Base, unsigned long Size)
  1233. +{
  1234. + unsigned long alignOff = Base - (Base & ~(getpagesize() - 1));
  1235. + munmap((caddr_t)(Base - alignOff), (Size + alignOff));
  1236. + nv_card->mem_mapped = 0;
  1237. +}
  1238. +
  1239. +/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
  1240. +dev_handle_t* open_dev(const char *dev_name)
  1241. +{
  1242. + dev_handle_t *dev;
  1243. + int fd;
  1244. +
  1245. + if( (fd = open(dev_name, O_RDWR)) == -1 )
  1246. + {
  1247. + char err[80];
  1248. + sprintf(err, "Can't open %s", dev_name);
  1249. + set_error_str(err);
  1250. + return NULL;
  1251. + }
  1252. +
  1253. + dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
  1254. + dev->fd = fd;
  1255. + return dev;
  1256. +}
  1257. +
  1258. +/* Close the devide handle */
  1259. +void close_dev(dev_handle_t *dev)
  1260. +{
  1261. + if(!dev)
  1262. + return;
  1263. +
  1264. + close(dev->fd);
  1265. + free(dev);
  1266. +}
  1267. Index: b/src/backend/backend.h
  1268. ===================================================================
  1269. --- a/src/backend/backend.h 2010-06-05 14:45:33.708537666 +0200
  1270. +++ b/src/backend/backend.h 2010-06-05 14:46:24.944536740 +0200
  1271. @@ -1,6 +1,6 @@
  1272. /* NVClock 0.8 - Linux overclocker for NVIDIA cards
  1273. *
  1274. - * Copyright(C) 2001-2005 Roderick Colenbrander
  1275. + * Copyright(C) 2001-2009 Roderick Colenbrander
  1276. *
  1277. * site: http://nvclock.sourceforge.net
  1278. *
  1279. @@ -42,12 +42,20 @@
  1280. /* Set the card object to the requested card */
  1281. int set_card(int number);
  1282.  
  1283. +/* This structure is used to abstract file descriptors away for mmap/unmmap. It will make sense when win32 support will be reactivated */
  1284. +typedef struct dev_handle
  1285. +{
  1286. + int fd;
  1287. +} dev_handle_t;
  1288. +
  1289. /* Some internally needed functions */
  1290. const char* get_card_name(int device_id, gpu_type *gpu);
  1291. int get_gpu_arch(int device_id);
  1292. int set_card_info(int number); /* Basic version of set_card */
  1293. -int map_mem(const char* dev_name);
  1294. -void unmap_mem();
  1295. +dev_handle_t* open_dev(const char *dev_name);
  1296. +void close_dev(dev_handle_t *dev);
  1297. +void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size);
  1298. +void unmap_dev_mem (unsigned long Base, unsigned long Size);
  1299. int32_t pciReadLong(unsigned short devbusfn, long offset);
  1300.  
  1301. /* Bios related stuff */
  1302. Index: b/src/backend/bios.c
  1303. ===================================================================
  1304. --- a/src/backend/bios.c 2010-06-05 14:45:33.712537072 +0200
  1305. +++ b/src/backend/bios.c 2010-06-05 14:46:24.944536740 +0200
  1306. @@ -48,6 +48,8 @@
  1307. static unsigned int locate(char *rom, char *str, int offset);
  1308. struct nvbios *read_bios(const char *file);
  1309. static struct nvbios *parse_bios(char *rom);
  1310. +int load_bios_file(const char* filename, char *data);
  1311. +int load_bios_prom(char *data);
  1312.  
  1313. typedef struct
  1314. {
  1315. @@ -101,7 +103,6 @@
  1316. short i, num_entries;
  1317. unsigned char start;
  1318. unsigned char size;
  1319. - int tmp = 0;
  1320.  
  1321. /* read how far away the start is */
  1322. start = rom[offset];
  1323. @@ -377,45 +378,12 @@
  1324. static void parse_bit_init_script_table(struct nvbios *bios, char *rom, int init_offset, int len)
  1325. {
  1326. int i,offset;
  1327. - int done=0;
  1328. unsigned char id;
  1329.  
  1330. + /* Read all init tables and print some debug info */
  1331. /* Table 1 */
  1332. offset = READ_SHORT(rom, init_offset);
  1333.  
  1334. - /* For pipeline modding purposes we cache 0x1540 and for PLL generation the PLLs */
  1335. - id = rom[offset];
  1336. - while(id != 'q')
  1337. - {
  1338. - offset = bit_init_script_table_get_next_entry(rom, offset);
  1339. - /* Break out of the loop if we find an unknown entry id */
  1340. - if(!offset)
  1341. - break;
  1342. - id = rom[offset];
  1343. -
  1344. - if(id == 'z')
  1345. - {
  1346. - int reg = READ_INT(rom, offset+1);
  1347. - unsigned int val = READ_INT(rom, offset+5);
  1348. - switch(reg)
  1349. - {
  1350. - case 0x1540:
  1351. - bios->pipe_cfg = val;
  1352. - break;
  1353. - case 0x4000:
  1354. - bios->nvpll = val;
  1355. - break;
  1356. - case 0x4020:
  1357. - bios->mpll = val;
  1358. - break;
  1359. - }
  1360. - }
  1361. - }
  1362. -
  1363. -#if DEBUG /* Read all init tables and print some debug info */
  1364. -/* Table 1 */
  1365. - offset = READ_SHORT(rom, init_offset);
  1366. -
  1367. for(i=0; i<=len; i+=2)
  1368. {
  1369. /* Not all tables have to exist */
  1370. @@ -426,7 +394,9 @@
  1371. continue;
  1372. }
  1373.  
  1374. +#if DEBUG
  1375. printf("Init script table %d\n", i/2+1);
  1376. +#endif
  1377. id = rom[offset];
  1378.  
  1379. while(id != 'q')
  1380. @@ -435,10 +405,33 @@
  1381. if(!offset)
  1382. break;
  1383.  
  1384. +#if DEBUG
  1385. if(!(id == 'K' || id == 'n' || id == 'x' || id == 'y' || id == 'z'))
  1386. printf("'%c' (%x)\n", id, id);
  1387. +#endif
  1388. offset = bit_init_script_table_get_next_entry(rom, offset);
  1389. id = rom[offset];
  1390. +
  1391. + if(id == 'z')
  1392. + {
  1393. + int reg = READ_INT(rom, offset+1);
  1394. + unsigned int val = READ_INT(rom, offset+5);
  1395. + switch(reg)
  1396. + {
  1397. + case 0x1540:
  1398. + bios->pipe_cfg = val;
  1399. + break;
  1400. + case 0x4000:
  1401. + bios->nvpll = val;
  1402. + break;
  1403. + case 0x4020:
  1404. + bios->mpll = val;
  1405. + break;
  1406. + case (NV_PDISPLAY_OFFSET + NV_PDISPLAY_SOR0_REGS_BRIGHTNESS):
  1407. + bios->pdisplay_brightness = val;
  1408. + break;
  1409. + }
  1410. + }
  1411. }
  1412.  
  1413. /* Pointer to next init table */
  1414. @@ -446,8 +439,6 @@
  1415. /* Get location of next table */
  1416. offset = READ_SHORT(rom, init_offset);
  1417. }
  1418. -#endif
  1419. -
  1420. }
  1421.  
  1422.  
  1423. @@ -881,55 +872,6 @@
  1424. return 0;
  1425. }
  1426.  
  1427. -
  1428. -#if DEBUG
  1429. -int main(int argc, char **argv)
  1430. -{
  1431. - read_bios("bios.rom");
  1432. - return 0;
  1433. -}
  1434. -
  1435. -
  1436. -#else
  1437. -void dump_bios(const char *filename)
  1438. -{
  1439. - int i;
  1440. - FILE *fp = NULL;
  1441. - char *rom = calloc(NV_PROM_SIZE, sizeof(char));
  1442. -
  1443. - if(!rom)
  1444. - {
  1445. - fprintf(stderr, "Unable to allocate memory for shadowing the bios image\n");
  1446. - return;
  1447. - }
  1448. -
  1449. - /* Try to obtain a copy of the bios first from PRAMIN later from the (slow) ROM.
  1450. - / Dumping from ROM might fail on laptops as for some reason there is no ROM on some laptops.
  1451. - */
  1452. - if(!load_bios_pramin(rom))
  1453. - {
  1454. - if(!load_bios_prom(rom))
  1455. - {
  1456. - fprintf(stderr, "Unable to shadow the video bios\n");
  1457. - free(rom);
  1458. - return;
  1459. - }
  1460. - }
  1461. -
  1462. - /* Try to dump the bios to a file */
  1463. - fp = fopen(filename, "w+");
  1464. - if(!fp) return;
  1465. -
  1466. - for(i=0; i<NV_PROM_SIZE; i++)
  1467. - {
  1468. - fprintf(fp, "%c", rom[i]);
  1469. - }
  1470. - fclose(fp);
  1471. -
  1472. - free(rom);
  1473. -}
  1474. -#endif
  1475. -
  1476. /* Verify if we are dealing with a valid bios image */
  1477. int verify_bios(char *rom)
  1478. {
  1479. @@ -946,7 +888,6 @@
  1480. int load_bios_file(const char* filename, char *data)
  1481. {
  1482. int fd = 0;
  1483. - int i = 0;
  1484. char *rom = NULL;
  1485.  
  1486. if((fd = open(filename, O_RDONLY)) == -1)
  1487. @@ -969,10 +910,10 @@
  1488. return 0;
  1489. }
  1490.  
  1491. +#ifndef DEBUG
  1492. /* Load the bios from video memory. Note it might not be cached there at all times. */
  1493. int load_bios_pramin(char *data)
  1494. {
  1495. - int i;
  1496. char *bios;
  1497. uint32_t old_bar0_pramin = 0;
  1498.  
  1499. @@ -1041,6 +982,7 @@
  1500. else
  1501. return 0;
  1502. }
  1503. +#endif
  1504.  
  1505. /* This function tries to read a copy of the bios from harddrive. If that doesn't
  1506. exist it will dump the bios and then read it. You might wonder why we don't read the bios from
  1507. @@ -1055,6 +997,13 @@
  1508. if(!rom)
  1509. return NULL;
  1510.  
  1511. +#if DEBUG
  1512. + if(!load_bios_file(file, rom))
  1513. + {
  1514. + free(rom);
  1515. + return NULL;
  1516. + }
  1517. +#else
  1518. if(!load_bios_pramin(rom))
  1519. {
  1520. if(!load_bios_file(file, rom))
  1521. @@ -1063,6 +1012,7 @@
  1522. return NULL;
  1523. }
  1524. }
  1525. +#endif
  1526.  
  1527. /* Do the actual bios parsing */
  1528. res = parse_bios(rom);
  1529. @@ -1098,7 +1048,7 @@
  1530. device_id = READ_SHORT(rom, pcir_offset + 6);
  1531. if(get_gpu_arch(device_id) & (NV4X | NV5X))
  1532. {
  1533. - /* For NV40 card the BIT structure is used instead of the BMP structure (last one doesn't exist anymore on 6600/6800le cards). */
  1534. + /* For NV40 card the BIT structure is used instead of the BMP structure (last one doesn't exist anymore on 6600/6800le cards). */
  1535. if(!(bit_offset = locate(rom, "BIT", 0)))
  1536. return NULL;
  1537.  
  1538. @@ -1189,3 +1139,49 @@
  1539. #endif
  1540. return bios;
  1541. }
  1542. +
  1543. +#if DEBUG
  1544. +int main(int argc, char **argv)
  1545. +{
  1546. + read_bios("bios.rom");
  1547. + return 0;
  1548. +}
  1549. +#else
  1550. +void dump_bios(const char *filename)
  1551. +{
  1552. + int i;
  1553. + FILE *fp = NULL;
  1554. + char *rom = calloc(NV_PROM_SIZE, sizeof(char));
  1555. +
  1556. + if(!rom)
  1557. + {
  1558. + fprintf(stderr, "Unable to allocate memory for shadowing the bios image\n");
  1559. + return;
  1560. + }
  1561. +
  1562. + /* Try to obtain a copy of the bios first from PRAMIN later from the (slow) ROM.
  1563. + / Dumping from ROM might fail on laptops as for some reason there is no ROM on some laptops.
  1564. + */
  1565. + if(!load_bios_pramin(rom))
  1566. + {
  1567. + if(!load_bios_prom(rom))
  1568. + {
  1569. + fprintf(stderr, "Unable to shadow the video bios\n");
  1570. + free(rom);
  1571. + return;
  1572. + }
  1573. + }
  1574. +
  1575. + /* Try to dump the bios to a file */
  1576. + fp = fopen(filename, "w+");
  1577. + if(!fp) return;
  1578. +
  1579. + for(i=0; i<NV_PROM_SIZE; i++)
  1580. + {
  1581. + fprintf(fp, "%c", rom[i]);
  1582. + }
  1583. + fclose(fp);
  1584. +
  1585. + free(rom);
  1586. +}
  1587. +#endif
  1588. Index: b/src/backend/nvclock.h
  1589. ===================================================================
  1590. --- a/src/backend/nvclock.h 2010-06-05 14:45:33.712537072 +0200
  1591. +++ b/src/backend/nvclock.h 2010-06-05 14:46:24.944536740 +0200
  1592. @@ -179,6 +179,8 @@
  1593. unsigned int spll;
  1594.  
  1595. unsigned int pipe_cfg; /* Used to cache the NV4x pipe_cfg register */
  1596. +
  1597. + unsigned int pdisplay_brightness; /* Used for NV5x smartdimmer */
  1598. };
  1599.  
  1600. typedef struct {
  1601. @@ -248,7 +250,7 @@
  1602.  
  1603. /* Hardware monitoring */
  1604. short num_busses; /* Number of available i2c busses */
  1605. - I2CBusPtr busses[3]; /* I2C busses on the videocard; this bus is needed for communication with sensor chips */
  1606. + I2CBusPtr busses[4]; /* I2C busses on the videocard; this bus is needed for communication with sensor chips */
  1607. I2CDevPtr sensor; /* When a sensor chip is available, this device pointer can be used to access it */
  1608. 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 */
  1609. int (*get_board_temp)(I2CDevPtr dev); /* Temperature of the sensor chip or for example the ram chips */
  1610. Index: b/src/backend/back_linux.c
  1611. ===================================================================
  1612. --- a/src/backend/back_linux.c 2010-06-05 14:45:33.720536632 +0200
  1613. +++ b/src/backend/back_linux.c 2010-06-05 14:46:24.944536740 +0200
  1614. @@ -1,6 +1,6 @@
  1615. /* NVClock 0.8 - Linux overclocker for NVIDIA cards
  1616. *
  1617. - * Copyright(C) 2001-2007 Roderick Colenbrander
  1618. + * Copyright(C) 2001-2009 Roderick Colenbrander
  1619. *
  1620. * site: http://nvclock.sourceforge.net
  1621. *
  1622. @@ -37,8 +37,6 @@
  1623. static int IsVideoCard(unsigned short devbusfn);
  1624.  
  1625. static int probe_devices();
  1626. -static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size);
  1627. -static void unmap_dev_mem (unsigned long Base, unsigned long Size);
  1628.  
  1629. /* Check if we are using the closed source Nvidia drivers */
  1630. static int check_driver()
  1631. @@ -62,7 +60,7 @@
  1632. / For various versions the driver isn't initialized when X hasn't
  1633. / been started and it can crash then.
  1634. */
  1635. - if(sscanf(buffer,"%s %d %d",&name, &size, &used) != 3) continue;
  1636. + if(sscanf(buffer,"%s %d %d", name, &size, &used) != 3) continue;
  1637. {
  1638. if(strcmp(name, "NVdriver") == 0)
  1639. {
  1640. @@ -131,7 +129,7 @@
  1641. if(sscanf(buf,"%hx %x %x %x",&devbusfn, &dev, &irq, &reg_addr) != 4) continue;
  1642.  
  1643. /* Check if the card contains an Nvidia chipset */
  1644. - if((dev>>16) == 0x10de)
  1645. + if((dev>>16) == PCI_VENDOR_ID_NVIDIA)
  1646. {
  1647. /*
  1648. When we enter this block of code we know that the device contains some
  1649. @@ -199,8 +197,8 @@
  1650. static int IsVideoCard(unsigned short devbusfn)
  1651. {
  1652. int32_t pci_class = pciReadLong(devbusfn, 0x9);
  1653. - /* When the id isn't 0x03 the card isn't a vga card return 0 */
  1654. - if(((htonl(pci_class) >> 8) & 0xf) != 0x03)
  1655. + /* When the id isn't PCI_CLASS_VGA the card isn't a vga card return 0 */
  1656. + if(((htonl(pci_class) >> 8) & 0xf) != PCI_CLASS_VGA)
  1657. return 0;
  1658. else
  1659. return 1;
  1660. @@ -228,8 +226,10 @@
  1661. return -1;
  1662. }
  1663.  
  1664. -int map_mem(const char *dev_name)
  1665. +/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
  1666. +dev_handle_t* open_dev(const char *dev_name)
  1667. {
  1668. + dev_handle_t *dev;
  1669. int fd;
  1670.  
  1671. if( (fd = open(dev_name, O_RDWR)) == -1 )
  1672. @@ -237,48 +237,29 @@
  1673. char err[80];
  1674. sprintf(err, "Can't open %s", dev_name);
  1675. set_error_str(err);
  1676. - return 0;
  1677. + return NULL;
  1678. }
  1679. -
  1680. - /* Map the registers of the nVidia chip */
  1681. - nv_card->PEXTDEV = map_dev_mem(fd, nv_card->reg_address + 0x101000, 0x1000);
  1682. - nv_card->PFB = map_dev_mem(fd, nv_card->reg_address + 0x100000, 0x1000);
  1683. - /* normally pmc is till 0x2000 but extended it for nv40 */
  1684. - nv_card->PMC = map_dev_mem(fd, nv_card->reg_address + 0x000000, 0x2ffff);
  1685. - nv_card->PCIO = map_dev_mem(fd, nv_card->reg_address + 0x601000, 0x2000);
  1686. - nv_card->PDISPLAY = map_dev_mem(fd, nv_card->reg_address + NV_PDISPLAY_OFFSET, NV_PDISPLAY_SIZE);
  1687. - nv_card->PRAMDAC = map_dev_mem(fd, nv_card->reg_address + 0x680000, 0x2000);
  1688. - nv_card->PRAMIN = map_dev_mem(fd, nv_card->reg_address + NV_PRAMIN_OFFSET, NV_PRAMIN_SIZE);
  1689. - nv_card->PROM = map_dev_mem(fd, nv_card->reg_address + 0x300000, 0xffff);
  1690. -
  1691. - /* On Geforce 8xxx cards it appears that the pci config header has been moved */
  1692. - if(nv_card->arch & NV5X)
  1693. - nv_card->PBUS = map_dev_mem(fd, nv_card->reg_address + 0x88000, 0x100);
  1694. - else
  1695. - nv_card->PBUS = nv_card->PMC + 0x1800/4;
  1696.  
  1697. - nv_card->mem_mapped = 1;
  1698. - close(fd);
  1699. - return 1;
  1700. + dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
  1701. + dev->fd = fd;
  1702. + return dev;
  1703. }
  1704.  
  1705. -void unmap_mem()
  1706. +/* Close the devide handle */
  1707. +void close_dev(dev_handle_t *dev)
  1708. {
  1709. - unmap_dev_mem((unsigned long)nv_card->PEXTDEV, 0x1000);
  1710. - unmap_dev_mem((unsigned long)nv_card->PFB, 0x1000);
  1711. - unmap_dev_mem((unsigned long)nv_card->PMC, 0xffff);
  1712. - unmap_dev_mem((unsigned long)nv_card->PCIO, 0x2000);
  1713. - unmap_dev_mem((unsigned long)nv_card->PDISPLAY, NV_PDISPLAY_SIZE);
  1714. - unmap_dev_mem((unsigned long)nv_card->PRAMDAC, 0x2000);
  1715. - unmap_dev_mem((unsigned long)nv_card->PRAMIN, NV_PRAMIN_SIZE);
  1716. - unmap_dev_mem((unsigned long)nv_card->PROM, 0xffff);
  1717. + if(!dev)
  1718. + return;
  1719. +
  1720. + close(dev->fd);
  1721. + free(dev);
  1722. }
  1723.  
  1724. /* -------- mmap on devices -------- */
  1725. /* This piece of code is from nvtv a linux program for tvout */
  1726. /* The author of nvtv got this from xfree86's os-support/linux/lnx_video.c */
  1727. /* and he modified it a little */
  1728. -static void *map_dev_mem (int fd, unsigned long Base, unsigned long Size)
  1729. +void *map_dev_mem (dev_handle_t *dev, unsigned long Base, unsigned long Size)
  1730. {
  1731. void *base;
  1732. int mapflags = MAP_SHARED;
  1733. @@ -288,11 +269,11 @@
  1734. alignOff = Base - realBase;
  1735.  
  1736. base = mmap((caddr_t)0, Size + alignOff, PROT_READ|PROT_WRITE,
  1737. - mapflags, fd, (off_t)realBase);
  1738. + mapflags, dev->fd, (off_t)realBase);
  1739. return (void *) ((char *)base + alignOff);
  1740. }
  1741.  
  1742. -static void unmap_dev_mem (unsigned long Base, unsigned long Size)
  1743. +void unmap_dev_mem (unsigned long Base, unsigned long Size)
  1744. {
  1745. unsigned long alignOff = Base - (Base & ~(getpagesize() - 1));
  1746. munmap((caddr_t)(Base - alignOff), (Size + alignOff));
  1747. Index: b/src/backend/back_win32.c
  1748. ===================================================================
  1749. --- a/src/backend/back_win32.c 2010-06-05 14:45:33.720536632 +0200
  1750. +++ b/src/backend/back_win32.c 2010-06-05 14:46:24.944536740 +0200
  1751. @@ -1,6 +1,6 @@
  1752. /* NVClock 0.8 - Linux overclocker for NVIDIA cards
  1753. *
  1754. - * Copyright(C) 2001-2007 Roderick Colenbrander
  1755. + * Copyright(C) 2001-2009 Roderick Colenbrander
  1756. *
  1757. * site: http://nvclock.sourceforge.net
  1758. *
  1759. @@ -57,7 +57,7 @@
  1760. if(lib_memacc == NULL)
  1761. {
  1762. set_error_str("Can't open MemAcc.dll\n");
  1763. - return 0;
  1764. + return 0;
  1765. }
  1766.  
  1767. pOpenLibrary = (void*)GetProcAddress(lib_memacc, "maOpenLibrary");
  1768. @@ -100,7 +100,7 @@
  1769. /* Check whether the vendor is nvidia and the BaseClass == VGA */
  1770. if(vendor_id == 0x10de && pCfg.BaseClass == 0x3)
  1771. {
  1772. - printf("Found VendorID: 0x%x DeviceID: 0x%x\r\n", vendor_id, device_id);
  1773. +// printf("Found VendorID: 0x%x DeviceID: 0x%x\r\n", vendor_id, device_id);
  1774.  
  1775. nvclock.card[i].device_id = device_id;
  1776. nvclock.card[i].arch = get_gpu_arch(nvclock.card[i].device_id);
  1777. @@ -126,38 +126,30 @@
  1778. return -1;
  1779. }
  1780.  
  1781. -int map_mem(const char *dev_name)
  1782. +/* Retrieve a handle to /dev/mem or /dev/nvidiaX */
  1783. +dev_handle_t* open_dev(const char *dev_name)
  1784. +{
  1785. + dev_handle_t *dev;
  1786. +
  1787. + dev = (dev_handle_t*)calloc(1, sizeof(dev_handle_t));
  1788. +// dev->fd = fd;
  1789. + return dev;
  1790. +}
  1791. +
  1792. +/* Close the devide handle */
  1793. +void close_dev(dev_handle_t *dev)
  1794. {
  1795. - void *hmem; // do nothing with this for now
  1796. - /* Map the registers of the nVidia chip */
  1797. - nv_card->PEXTDEV = pMapPhysToLinear(nv_card->reg_address + 0x101000, 0x1000, &hmem);
  1798. - nv_card->PFB = pMapPhysToLinear(nv_card->reg_address + 0x100000, 0x1000, &hmem);
  1799. - /* normally pmc is till 0x2000 but extended it for nv40 */
  1800. - nv_card->PMC = pMapPhysToLinear(nv_card->reg_address + 0x000000, 0x2ffff, &hmem);
  1801. - nv_card->PCIO = pMapPhysToLinear(nv_card->reg_address + 0x601000, 0x2000, &hmem);
  1802. - nv_card->PDISPLAY = pMapPhysToLinear(nv_card->reg_address + NV_PDISPLAY, NV_PDISPLAY_LENGTH, &hmem);
  1803. - nv_card->PRAMDAC = pMapPhysToLinear(nv_card->reg_address + 0x680000, 0x2000, &hmem);
  1804. - nv_card->PROM = pMapPhysToLinear(nv_card->reg_address + 0x300000, 0xffff, &hmem);
  1805. -
  1806. - /* On Geforce 8xxx cards it appears that the pci config header has been moved */
  1807. - if(nv_card->arch & NV5X)
  1808. - nv_card->PBUS = pMapPhysToLinear(nv_card->reg_address + 0x88000, 0x100, &hmem);
  1809. - else
  1810. - nv_card->PBUS = nv_card->PMC + 0x1800/4;
  1811.  
  1812. - nv_card->mem_mapped = 1;
  1813. - return 1;
  1814. }
  1815.  
  1816. -void unmap_mem()
  1817. +void *map_dev_mem(dev_handle_t *dev, unsigned long Base, unsigned long Size)
  1818. {
  1819. -#if 0
  1820. - pUnMapIO(winio, (void*)nv_card->PEXTDEV);
  1821. - pUnMapIO(winio, (void*)nv_card->PFB);
  1822. - pUnMapIO(winio, (void*)nv_card->PMC);
  1823. - pUnMapIO(winio, (void*)nv_card->PCIO);
  1824. - pUnMapIO(winio, (void*)nv_card->PRAMDAC);
  1825. - pUnMapIO(winio, (void*)nv_card->PROM);
  1826. - nv_card->mem_mapped = 0;
  1827. -#endif
  1828. + void *hmem;
  1829. + return pMapPhysToLinear(Base, Size, &hmem);
  1830. +}
  1831. +
  1832. +
  1833. +void unmap_dev_mem(unsigned long Base, unsigned long Size)
  1834. +{
  1835. +
  1836. }
  1837. Index: b/src/backend/w83781d.c
  1838. ===================================================================
  1839. --- a/src/backend/w83781d.c 2010-06-05 14:45:33.728536611 +0200
  1840. +++ b/src/backend/w83781d.c 2010-06-05 14:46:24.944536740 +0200
  1841. @@ -73,9 +73,11 @@
  1842.  
  1843. float w83781d_get_fanspeed_pwm(I2CDevPtr dev)
  1844. {
  1845. + return 0.0;
  1846. }
  1847.  
  1848. int w83781d_set_fanspeed_pwm(I2CDevPtr dev, float speed)
  1849. {
  1850. + return 0;
  1851. }
  1852.  
  1853. Index: b/src/backend/nv30.c
  1854. ===================================================================
  1855. --- a/src/backend/nv30.c 2010-06-05 14:45:33.736536575 +0200
  1856. +++ b/src/backend/nv30.c 2010-06-05 14:46:24.944536740 +0200
  1857. @@ -178,7 +178,7 @@
  1858. static void nv30_set_gpu_speed(unsigned int nvclk)
  1859. {
  1860. unsigned int PLL=0;
  1861. - int m1, m2, n1, n2, p;
  1862. + unsigned int m1, m2, n1, n2, p;
  1863. nvclk *= 1000;
  1864.  
  1865. p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
  1866. @@ -200,7 +200,7 @@
  1867. static void nv31_set_gpu_speed(unsigned int nvclk)
  1868. {
  1869. unsigned int PLL, PLL2;
  1870. - int m1, m2, n1, n2, p;
  1871. + unsigned int m1, m2, n1, n2, p;
  1872. nvclk *= 1000;
  1873.  
  1874. p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
  1875. @@ -241,7 +241,7 @@
  1876. static void nv30_set_memory_speed(unsigned int memclk)
  1877. {
  1878. unsigned int PLL=0;
  1879. - int m1, m2, n1, n2, p;
  1880. + unsigned int m1, m2, n1, n2, p;
  1881. memclk *= 1000;
  1882.  
  1883. p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
  1884. @@ -260,7 +260,7 @@
  1885. static void nv31_set_memory_speed(unsigned int memclk)
  1886. {
  1887. unsigned int PLL, PLL2;
  1888. - int m1, m2, n1, n2, p;
  1889. + unsigned int m1, m2, n1, n2, p;
  1890. memclk *= 1000;
  1891.  
  1892. p = NV30_PLL_P(nv_card->PRAMDAC[0x500/4]);
  1893. Index: b/src/backend/nv50.c
  1894. ===================================================================
  1895. --- a/src/backend/nv50.c 2010-06-05 14:45:33.736536575 +0200
  1896. +++ b/src/backend/nv50.c 2010-06-05 14:46:24.944536740 +0200
  1897. @@ -166,13 +166,18 @@
  1898. if(speed < 10 || speed > 100)
  1899. return;
  1900.  
  1901. + /* Note Oxe300 is also related to the fanspeed. By default it seems to contain 0x100 on
  1902. + / 9600GT and other cards. Setting this value to 0x300 seems to set the fanspeed to a fixed
  1903. + / value. Apparently 0xe300 acts like a multiplexer?
  1904. + / On some boards this magical bit9 (0x200) is set by the drivers sometimes which prevents
  1905. + / fanspeed adjustment. Clear this bet when needed.
  1906. + */
  1907. + if(nv_card->PMC[0xe300/4] & (1<<9))
  1908. + nv_card->PMC[0xe300/4] &= ~(1<<9);
  1909. +
  1910. /* Bit31 must be set else the hardware doesn't seem to do anything with the changes
  1911. / Bit30-16 contain some magical bits on 9500GT and other cards which we should preserve.
  1912. / On a 9500gt the contents of 0xe120 could be e.g. 0x0300010e with a pwm_divider of 0x21d.
  1913. - /
  1914. - / Note Oxe300 is also related to the fanspeed. By default it seems to contain 0x100 on
  1915. - / 9600GT and other cards. Setting this value to 0x300 seems to set the fanspeed to a fixed
  1916. - / value. Apparently 0xe300 acts like a multiplexer?
  1917. */
  1918. value = 0x80000000 | (nv_card->PMC[0xe120/4] & 0x7fff0000) | (((int)(100 - speed) * pwm_divider/100) & 0x7fff);
  1919. nv_card->PMC[0xe120/4] = value;
  1920. @@ -404,12 +409,16 @@
  1921. / FZ21E, FZ21M, FZ470E, FZ340E, FZ190N, FZ18M, FZ31E, FZ18E, FZ31Z, FZ21Z, FZ31S, AR51SU, AR71S
  1922. / - Zepto (unknown model), Geforce 9600M, dev=0x649, subvendor=0x1a46,
  1923. */
  1924. +#if 0
  1925. if((nv_card->gpu == MOBILE) &&
  1926. ((nv_card->subvendor_id == PCI_VENDOR_ID_APPLE) ||
  1927. (nv_card->subvendor_id == PCI_VENDOR_ID_HP) ||
  1928. (nv_card->subvendor_id == PCI_VENDOR_ID_SANYO) ||
  1929. (nv_card->subvendor_id == PCI_VENDOR_ID_SONY) ||
  1930. (nv_card->subvendor_id == PCI_VENDOR_ID_ZEPTO)))
  1931. +#endif
  1932. + /* Detect the presence of smartdimmer depending on whether the bios initialized the register */
  1933. + if(nv_card->bios && nv_card->bios->pdisplay_brightness)
  1934. {
  1935. nv_card->caps |= SMARTDIMMER;
  1936. nv_card->get_smartdimmer = nv50_mobile_get_smartdimmer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement