It is currently Tue Dec 10, 2019 5:02 pm



Reply to topic  [ 32 posts ] 
 Compiling and using Genlock on Linux 
Author Message
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Hello,

I've modified the Genlock application (based on SoftGenLock) to make it work with recent kernels, 2.6.32 in my case. One of the goals of this application is to provide a kernel module to do page flipping active stereo with consumer NVIDIA cards on Linux (ie. not Quadro only). I don't know with which cards it's compatible, but I've tested it successfully on my GeForce 7600 GT (AGP) and the authors used it with a GeForce 4, so I guess it'll work on most NVIDIA graphic cards.

You'll find the tarball in the attachement provided below : genlock-20100615.tar.gz.

*** How to compile it ***

First, you need to untar the archive. From the command line :
Code:
tar xvfz genlock-20100615.tar.gz
Then, go to the directory where the files have been untarred and compile the code :
Code:
cd genlock-20100615 ; make
You should only see some minor warnings and a message similar to this one at the end :
Code:
Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/frederic/tarred/stereo/genlock-20100615/genlock.mod.o
  LD [M]  /home/frederic/tarred/stereo/genlock-20100615/genlock.ko
make[1]: quittant le répertoire « /usr/src/linux-headers-2.6.32-5-686 »
Finally, you'll need to install the module as root by typing :
Code:
make install

*** How to load it ***

If all went well during the compilation and installation of the genlock module, you need to load it. First, you'll need to unload parallel port modules because they interfer with it and will cause a kernel oops :
Code:
rmmod parport_pc
rmmod parport
rmmod lp
Now, you can load the genlock module :
Code:
modprobe genlock
If no message is displayed, it means the module has been correctly loaded. You can verify its state by typing :
Code:
cat /proc/driver/genlock/state
It should display this message, indicated it is in slave mode and that it's disabled for now :
Code:
slave: disabled [mono]

*** How to use it ***

To use this module, you need to configure a virtual screen twice the width of your current resolution by either modifying /etc/X11/xorg.conf or by using nvidia-settings. When activated, the module will display the left and the right part of the virtual screen alternatively in synchronisation with the vertical retrace.

For the nvidia-settings method, go to X Server Display Configuration, click on the Advanced... button, type 2048x768 (where 2048 is twice your current width and 768 your current height) in the Panning edit box then click on Apply.

For the xorg.conf method, add the line marked with an arrow (without typing the arrow of course) in the "Display" subsection of your "Screen" section :
Code:
Section "Screen"
    ...
    SubSection     "Display"
        Depth       24
        Modes       "1024x768"
->      Virtual     2048 768
    EndSubSection
    ...
EndSection
To test the module, you'll need LCD shutter glasses than can be automatically synchronized to the vertical retrace. If you own eDimensional glasses you can do so by using the activator written by mickeyjaw (dongleactivator.tar.gz) or the one provided by eDimensional (E-D.exe) which should work with Wine.

To activate the page flipping mode, just type this line in a terminal :
Code:
echo stereo > /proc/driver/genlock/state
You can disable the page flipping by typing :
Code:
echo mono > /proc/driver/genlock/state
When the stereo mode is active, you should be able to see the left part of your virtual screen on one eye and the right part on the other eye.

There are some options you should be able to modify by accessing the files in /proc/driver/genlock or passing parameters when you load the genlock module. I didn't try yet, but feel free to have a look at these files or refer to the documentation of either Genlock or SoftGenLock.

*** Caveats***

There is one major caveat with this module on my machine, it does work correctly only when I'm in a 60 Hz DoubleScan mode. When I choose an higher vertical frequency, the screen swaps are no longer synchronized to the vertical retrace and I've got this message in syslog :
Code:
[ 2416.429192] genlock: PROBABLY OUT OF SYNC - time between expected and real irq: 6165 us, frametime 16716 us, 2 skipped, lastdiff -10298 us
I don't know why it's getting out of sync, I'll need to investigate a little bit in the code to find out. I hope it won't be the same on your machine though.

To make a better use of this application, you should try to display two different images in each part of the virtual screen, for example by writing an OpenGL application with a two cameras that render their views respectively in a (0, 0, 1024, 768) and a (1024, 0, 2048, 768) rectangle.

If you try this application, don't hesitate to report back in this thread how it does work for you.

Thank you.


You do not have the required permissions to view the files attached to this post.


Last edited by Fredz on Tue Jun 15, 2010 11:11 am, edited 1 time in total.



Tue Jun 15, 2010 12:23 am
Profile WWW
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Good news, I had a deeper look into the code and there are no more missed vertical retraces for higher refresh rates now, it does even work on my CRT at 120 Hz. There is still the occasional missed one sometimes, but it happens quite rarely and it's detected by Genlock anyway.

I got the problem because I was changing the vertical refresh rate of my display when genlock was already loaded. Since there is some initialization code to calculate the duration of a frame at startup, you need to unload Genlock, change the frequency of your monitor, then reload it to make it work for the new refresh rate. Maybe you can do the same with some twiddling with the files in /proc/driver/genlock but I didn't try yet.

Anyway, that's great news and I would be really happy if anyone could report success on his/her machine, because if it's reported to work that would open a whole new world for 3D video players and S3D drivers for Linux. For NVIDIA cards only for now though, but with great chances to produce something better than iZ3D/Trider drivers...


Tue Jun 15, 2010 9:04 am
Profile WWW
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Forgot to tell that the impact on the system was minimal too, I didn't see any difference in CPU usage with and without the genlock module using the top command. Seems logical since it's based on hardware interrupts (IRQ) and hardware page flipping, ie. there are no copies in video memory, just a reprogrammation of the CRTC to make it point to another part of the screen.


Tue Jun 15, 2010 9:13 am
Profile WWW
Cross Eyed!

Joined: Sun Feb 15, 2009 12:50 pm
Posts: 131
Reply with quote
Wow!!!

I will try this as soon as I get home tonight. I was hoping a proper kernel module would reduce the CPU requirements, and it looks like it does. This will make implementing page flipping in Tux-Stereo-Viewer really easy!

You do know the parallel port conflict is because Genlock sends out a VESA sync signal on the parallel port right? If you wire an adapter DB25-DIN3 then your glasses will always be in sync because Genlock knows when it has missed a frame...

Also, does Genlock have a hard-coded screen resolution like SoftGenLock did, is resolution detection automatic, or is there a config file/sysfs/procfs node somewhere where you can set the screen res?

Edit: Found this line:

Code:
static int rightoffset = 1024


BADBADBADBAD!!!
Yuck! :( This is absolutely NOT the way to code a kernel module!

I know it's not your fault Fredz (It was in Martin Aumueller's original code too), but can we please get a procfs node to set this from userspace without having to recompile every time we change screen res, or do i misunderstand and this can be set as a module option when inserting?


Wed Jun 16, 2010 6:18 am
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
mickeyjaw wrote:
Wow!!!
I felt exactly the same when I got it to compile... :)

mickeyjaw wrote:
You do know the parallel port conflict is because Genlock sends out a VESA sync signal on the parallel port right?
I intend to suppress code related to genlocking/framelocking and parallel port access in a near future.

mickeyjaw wrote:
Yuck! :( This is absolutely NOT the way to code a kernel module!
Quite, I didn't saw that, I only tested in 1024x768.

mickeyjaw wrote:
I know it's not your fault Fredz (It was in Martin Aumueller's original code too), but can we please get a procfs node to set this from userspace without having to recompile every time we change screen res, or do i misunderstand and this can be set as a module option when inserting?
Yes, I think it should be feasible to modify it with an access to procfs. I wanted to detect resolution and frame duration automatically when the user activates page flip, I'll test both ways I guess.

By the way, I tested it with MPlayer and it worked quite well, but I need to add code for the missed retraces and eye inversion : Viewing S3D videos with MPlayer on Linux using Genlock.


Wed Jun 16, 2010 10:41 am
Profile WWW
Cross Eyed!

Joined: Sun Feb 15, 2009 12:50 pm
Posts: 131
Reply with quote
Fredz wrote:
I intend to suppress code related to genlocking/framelocking and parallel port access in a near future.


Please, if it is not too much trouble don't remove it completely - maybe you could #ifdef it instead. I think the square wave on the parallel port may be useful for debugging timing issues as well as for people who have a video card without support for DDC. It would also be nice to be able to genlock multiple cards / outputs on the same machine for multi-monitor setups, although i don't know if this falls within the capability of the original SGL code or not?

Anyway, I am off to try compiling against 2.6.28 ubuntu kernel, wish me luck!


Wed Jun 16, 2010 11:32 am
Profile
Cross Eyed!

Joined: Sun Feb 15, 2009 12:50 pm
Posts: 131
Reply with quote
Just a quick message to let you know it compiles and runs well at 1024x768&120hz here on Ubuntu 9.04 (kernel 2.6.28)

Edit: It works fine with one monitor, but with two monitors in TwinView it acts very strange. I would setup separate X screens, but then all sorts of other things on my PC will break. Oh well I guess I will have to put up with only one stereo screen at a time :P


Wed Jun 16, 2010 11:50 am
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
mickeyjaw wrote:
Please, if it is not too much trouble don't remove it completely - maybe you could #ifdef it instead. I think the square wave on the parallel port may be useful for debugging timing issues as well as for people who have a video card without support for DDC.
Ok, I'll leave the code for driving glasses from the parallel port then.
mickeyjaw wrote:
It would also be nice to be able to genlock multiple cards / outputs on the same machine for multi-monitor setups, although i don't know if this falls within the capability of the original SGL code or not?
I don't think SoftGenLock/Genlock can do that from reading the docs and the code. I think genlocking/framelocking does only work with multiple PCs, not multiple cards in the same PC. I'll remove this code and add a line for multi-monitor support in my todo list.
mickeyjaw wrote:
Just a quick message to let you know it compiles and runs well at 1024x768&120hz here on Ubuntu 9.04 (kernel 2.6.28)
Nice, with which of your 3 graphic cards did you test it (7900 GT, 7900 GTX, 8400 GS) ? And which bus type (PCI/AGP/PCIe) ?


Wed Jun 16, 2010 12:26 pm
Profile WWW
Cross Eyed!

Joined: Sun Feb 15, 2009 12:50 pm
Posts: 131
Reply with quote
Quote:
Nice, with which of your 3 graphic cards did you test it (7900 GT, 7900 GTX, 8400 GS) ? And which bus type (PCI/AGP/PCIe) ?


I used the 7900GTX (16X PCI-Express) with the NVIDA proprietary drivers version 180.44

I'm guessing that it will work exactly the same with the 7900GT so I won't bother trying it, but I may try the 8400 when I can be bothered to try finding it (I just moved house and lots of things are still in cardboard boxes)

On another subject, do you know any way to reliably set resolution/refresh from the command line when using NVIDIA drivers? XRandR seems to be completely broken on my system and I am trying to write a shell script to set refresh/resolution, start genlock, run mplayer then stop genlock and restore display settings again after mplayer exits.


Wed Jun 16, 2010 1:25 pm
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
mickeyjaw wrote:
On another subject, do you know any way to reliably set resolution/refresh from the command line when using NVIDIA drivers? XRandR seems to be completely broken on my system and I am trying to write a shell script to set refresh/resolution, start genlock, run mplayer then stop genlock and restore display settings again after mplayer exits.
Yep, it's a bit annoying to have to use the GUI each time, I didn't try with the command line yet. Here is a link to a method that could work, involving nv-control-dpy and xrandr :
http://stuvel.eu/archive/75/selecting-n ... ommandline


Wed Jun 16, 2010 2:57 pm
Profile WWW
Cross Eyed!

Joined: Sun Feb 15, 2009 12:50 pm
Posts: 131
Reply with quote
Thanks, but i have already built nv-control-dpy. It is not setting up a metamode that is the problem, but switching to it using xrandr. Sometimes i can switch to a mode (usually of a lower resolution), but most of the time i get something like this:

Code:
mike@mike-desktop:~/Desktop/nvidia/nvidia-settings-180.25/samples$ xrandr
Screen 0: minimum 1024 x 768, current 3520 x 1200, maximum 3968 x 1200
default connected 3520x1200+0+0 0mm x 0mm
   3520x1200      50.0     52.0     53.0*
   1024x768       51.0     52.0 
   2024x768       50.0 
   1600x1200      52.0 
   3968x1200      52.0     50.0 
   3968x1080      50.0     53.0 
   1680x1050      51.0 
mike@mike-desktop:~/Desktop/nvidia/nvidia-settings-180.25/samples$ xrandr -s 1600x1200@52
Failed to change the screen configuration!
mike@mike-desktop:~/Desktop/nvidia/nvidia-settings-180.25/samples$ xrandr -s 1600x1200
Failed to change the screen configuration!


I did manage to switch to 1024x768 at one point, but then I couldn't switch back. I think maybe my xorg.conf is messed up or maybe it is a driver bug. At least it is good to know it works for someone, so I will have a play around with different driver versions and xorg configs and see where i get.


Wed Jun 16, 2010 3:18 pm
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Maybe you should upgrade to the latest version of the NVIDIA drivers ? I use the 195.36.24 with my 7600 GT and they work well for me.


Wed Jun 16, 2010 3:32 pm
Profile WWW
Cross Eyed!

Joined: Sun Feb 15, 2009 12:50 pm
Posts: 131
Reply with quote
Just to let you know that I cleaned up my xorg.conf, restarted X and now nv-control-dpy and xrandr work. I didn't need to change drivers at all. I wrote a dead simple shell scrips for playing side-by-side 720p movies (my normal desktop is 1600x1200@100hz CRT and 1920x1200@60hz LCD):

Code:
#!/bin/sh
nv-control-dpy --add-metamode '1024x768_120 @2048x768, NULL'
xrandr -s 2048x768
echo stereo > /proc/driver/genlock/state
mplayer $1 -vo x11 -vf dsize=1280x720,scale=2048:768 -fs
echo mono > /proc/driver/genlock/state
xrandr -s 3520x1200


Thanks a lot for doing this, I wish I could help more with the code cleanup, but my C is rather rusty and I've never done any kernel hacking before. I am reading through the code right now trying to make sense of it. Let me know if I can do anything to help - I may have a go at a copy-paste job to add a procfs interface for screen width and stereo reverse, but I expect it will probably crash and burn.


Fri Jun 18, 2010 5:03 am
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
mickeyjaw wrote:
Just to let you know that I cleaned up my xorg.conf, restarted X and now nv-control-dpy and xrandr work. I didn't need to change drivers at all. I wrote a dead simple shell scrips for playing side-by-side 720p movies (my normal desktop is 1600x1200@100hz CRT and 1920x1200@60hz LCD)
Nice and thanks for the script, I'll try it on my machine.

mickeyjaw wrote:
Let me know if I can do anything to help - I may have a go at a copy-paste job to add a procfs interface for screen width and stereo reverse, but I expect it will probably crash and burn.
Unfortunately the code lacks comments and is quite badly written, it's not going to be an easy task to modify it. From what I've seen, there could be a limit on the max resolution supported and that may be the reason why it is set at 1024 in the code.


Sun Jun 20, 2010 3:47 pm
Profile WWW
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Back on the subject. I've made some tests with CRTC registers programming and I'm able to do page flipping with higher resolutions than 1024x768 using VGA registers only. I've only tried with 1360x768 for now but I'll try with the other modes supported by my display (up to 1920x1080). Maybe this technique could be supported on other graphic cards (ATI, Intel, etc.) since it's standard VGA programming.

Concerning the hiccups when using TwinView, I've made some tests with IRQ interception and I've discovered that there is an interruption on the vertical retrace for each connected screen, which seems logical.

To handle this, one way would be to ignore the interrupts for one screen but I'd need a way to determine to which screen an interrupt does correspond. The second way would be to try to synchronize the frequency of the two outputs, something like this is done in SoftGenLock for graphic cards on separate machines but I don't know if it's possible for two outputs on a single card.

Another interesting thing is that with some tweaking of the xorg.conf file, I'm able to create a graphics mode with a virtual screen but without panning. I can't reproduce this programmaticaly and I'm not able to write something to the virtual part yet, but that's quite encouraging. So, there may be a way to create a virtual screen that behaves like a non-virtual screen transparently for the windowing system and the applications.


Wed Sep 01, 2010 2:54 pm
Profile WWW
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Here is some code to test the hardware page flipping (pageflip.c) :
Code:
/*
NAME
   pageflip - test hardware page flipping

SYNOPSIS
   pageflip <offset>

DESCRIPTION
   pageflip is used to test hardware page flipping on graphic cards
   supporting standard VGA registers while running an X Server.

   To obtain meaningful results, a virtual screen must be active with an
   horizontal resolution set to the double of the viewport horizontal
   resolution. For example, a 1024x768 viewport with a 2048x768 virtual
   screen.

   The application is controlled using these interactive commands:

   q   quit the application
   1   set the CRTC Start Address Register to 0
   2   set the CRTC Start Address Register to <offset>

OPTIONS
   <offset>
      Set the offset value as a number of pixel columns that should
      correspond to the width of the current viewport. For example
      1920 for a 3840x1080 virtual screen.

AUTHOR
   Frédéric Lopez <frederic.lopez@free.fr>

   12 September 2010
*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/io.h>
#include <errno.h>

// Define the Address Register for CRTC access
#define CRTC_ADDR_REG 0x3D4
// Define the Data Register for CRTC access
#define CRTC_DATA_REG 0x3D5

// Set the CRTC Start Adress Register
static void set_vga_start(int offset)
{
   // Set the CRTC Start Address Low Register
   outb(0x0D, CRTC_ADDR_REG);
   outb(offset & 0xFF, CRTC_DATA_REG);

   // Set the CRTC Start Address High Register
   outb(0x0C, CRTC_ADDR_REG);
   outb(offset >> 8, CRTC_DATA_REG);
}

int main(int argc, char *argv[])
{
   int key, offset;
   char *p;

   // Test the number of command-line arguments
   if (argc != 2)
   {
      printf("Usage: pageflip <offset>\n");
      exit(EXIT_FAILURE);
   }

   // Test if the argument is an integer
   errno = 0;
   offset = strtol(argv[1], &p, 10);
   if (errno != 0 || *p != 0 || p == argv[1])
   {
      printf("Error: offset value must be an integer!\n");
      exit(EXIT_FAILURE);
   }

   // Change the I/O privilege level to allow access to VGA registers
   if (iopl(3) != 0)
   {
      printf("Warning: unable to modify the I/O privilege level!\n");
   }

   // Show interactive commands help
   printf("Quit with 'q'.\n");
   printf("Page 1 with '1'.\n");
   printf("Page 2 with '2'.\n");
   
   while ((key = getchar()) != 'q')
   {
      switch (key)
      {
         case '1' :
            // Set Start Address Register to 0
            set_vga_start(0);
            printf("Page 1.\n");
            break;
         case '2' :
            // Set Start Address Register to <offset>
            set_vga_start(offset);
            printf("Page 2.\n");
            break;
      }
   }

   // Restore the default I/O privilege level
   if (iopl(0) != 0)
   {
      printf("Warning: unable to restore the default I/O privilege level!\n");
   }
   
   printf("Done.\n");
     
   return EXIT_SUCCESS;
}

You can compile the code using the following command :
    gcc -O2 -o pageflip pageflip.c

You must run it as the root user to gain access to the VGA registers. I'm not sure if it will work on other architectures than i386 or on other graphic cards than the NVIDIA ones but I'd be interested to know.

On my machine it does work on all the resolutions I've tested it on, ie. 1024x768, 1280x720, 1360x768 and 1920x1080 using virtual screens twice the horizontal resolution of the viewports.

Feel free to test it and to report back if it does work for you, giving your CPU and graphics card references.

Thanks.


Sun Sep 12, 2010 12:01 am
Profile WWW
One Eyed Hopeful

Joined: Sun Feb 20, 2011 8:07 pm
Posts: 6
Reply with quote
Hello,

I would like to experiment genlock but i don't think it works for me.
My graphic card is an Nvidia G210, ubuntu 10.04. I compile and install genlock successfully, did all you wrote but i don't manage to activate pageflip. I have a lot of OUT OF SYNC.

Mar 4 23:08:58 vdrbox-svr kernel: [ 1890.298858] genlock: PROBABLY OUT OF SYNC - time between expected and real irq: 11413 us, frametime 16702 us, 1 skipped, lastdiff -1504 us

When i try you're C program, it doesn't do anything than write Page 1, Page 2. No flipping. When i launch mplayer, samething.

Please, help...


Fri Mar 04, 2011 4:20 pm
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
I had lots of OUT OF SYNC messages too, but they weren't really a problem.

First you need to connect only one monitor to your GPU or the vertical retrace detection won't work correctly, then you need to remove all the modules related to the parallel port, and finally you must create a virtual screen with a double horizontal width.

When all this is done, you can send the command to activate stereo as explained in the first post.

You can also test the pageflip.c test code (which has nothing to do with Genlock) to see if your graphics card supports page flipping using standard VGA registers. You also need to use a virtual screen with a double horizontal resolution (2048x768 for example)

As I said it may not work with 64bit processors, I've only tested it on Geforce 7XXX and 8XXX GPUs, but I don't know if more recent models from NVIDIA support old VGA CRTC registers.


Fri Mar 04, 2011 7:21 pm
Profile WWW
One Eyed Hopeful

Joined: Sun Feb 20, 2011 8:07 pm
Posts: 6
Reply with quote
I'm afraid it will not work for me. I have a 64bit ubuntu. I exactly did all this things, unload unnecessary modules, compile pageflip.c, etc. I tested with geforce G210 and ati HD3650 with same results.
I'm sad cause i have a 3D vision kit. I can activate glasses in synch with vsync but i don't know how to "pageflip" my S3D video :(
Is there something i can do to debug / help to see what doesn't work ?

Thx for your help.

'Z


Sat Mar 05, 2011 2:12 am
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
I guess the problem can come from three things :

- only in pageflip.c : the "iopl" function call only work on 32 bits processors, so it can't change the I/O privilege level on 64 bits processors. This problem shouldn't happen with the Genlock module since it's a kernel module that work in a correct privilege level ;

- 64 bits processor may not be able to handle registers access with the outb function call in the same way 32 bits processors do, but I've no idea if it's really the case. You'd need someone to be able to test Genlock with a Geforce 7XXX/8XXX and a 64 bits proc to be sure ;

- NVIDIA may have dropped legacy VGA registers support in their new lines of graphics card, which would not be that surprising since they don't serve any purpose now. You would need someone with a machine known to work with a 7XXX/8XXX GPU and test it using a more recent GPU like the G210 to know ;

- I'm not even sure ATI GPUs ever were compatible with standard VGA registers ;

If it does not work with the technique I used, you could still try to have page-flipping support by using one of these two solutions :

The first one would be to do software page flipping by alternatively copying left and right images to the screen (XCopyArea or OpenGL functions) and use a function to synchronize the display with the vertical retrace (XSync or glXGetVideoSyncSGI/glXWaitVideoSyncSGI). I've tested this and it somewhat works for images and videos, but only when the decoding of the video and the copy of decoded images are very fast, else vertical retraces can be missed and eye inversion will occur.

The second option would be to identify the NVIDIA (or ATI) specific registers that handle the CRTC, in order to specify which part of the video memory to display. I've searched for them in the Nouveau driver without success, the code is extremly hard to follow for someone without a background in video driver programming. By looking at the code and finding someone able to explain it to you (on the IRC channel for Nouveau for example), you may find out how it does work.


Sat Mar 05, 2011 10:47 am
Profile WWW
One Eyed Hopeful

Joined: Wed Mar 09, 2011 4:35 am
Posts: 9
Reply with quote
Hello,
can you please advise?

I have
- Ubuntu 11.04 32 bit
- I compiled Bino
- I have a 3D 120hz DLP projector connected via HDMI
- (if useful also a VIP Gamer)
- NVIDIA GPU GeForce 8800 GT (non Quadro) (latest driver, 270)


The first issue I had was that in Windows I could set the refresh rate to 120hz and in Linux I could not from the "display" panel.
But then it was Ok in this way: from the NVIDIA driver: "GPU scaling"=OFF. Then the 120hz option became possible.


Is there a way to see in 3D from Bino?


Thanks for the advice. I am new to Linux: I am trying to move from Windows to Linux but still learning.


Sat Jun 25, 2011 8:42 pm
Profile
One Eyed Hopeful

Joined: Sat Jul 16, 2011 8:46 am
Posts: 5
Reply with quote
Fredz, first off, thank you for your effort in working with these 3d glasses in linux, I appreciate it.

I'd like to get my 3D glasses to work in linux, as they now only work on Windows XP with the old nvidia 3D Stereo drivers as they have dropped support for it years ago. I am much more proficient at linux in general as well. So, to this end, I have spent time this weekend to set up a freshly installed computer with Debian Squeeze on it. It has a GeForce 7300 GS, which I bought specifically to support my Stereo-3D LCD glasses.

First of all, I'd like to know if any of the code you've written so far will actually work with my glasses. I don't have a dongle, and it doesn't present an USB device (it just uses that for power). I think they are controlled solely by use of the DDC pin on the vga connector. From the other thread you started (ddc glasses), it would appear that you use some sort of dongle to make the glasses switch eyes? The glasses I have are these:

http://www.logictoyz.com/audio-video-/v ... ewear.html

So far, I've done these things to verify:

  • Setup Debian Squeeze with compiling tools
  • Configure Xorg to use 1024x768 with 2048x769 virtual screen size
  • Switch to nvidia driver (nouveau doesn't work with your pageflip example at all)
  • Compile and run pageflip. Works! As mentioned, I have a GeForce 7300 GS, over PCI Express 16x, but had to switch to nvidia driver first. Architecture is i386.
  • Compile and modify nvclock from the thread you started about the DDC VGA glasses. This runs (also requires nvidia driver), but doesn't do anything.

I have yet to dive into the genlock example, so that will be next. For now I'm mostly interested whether I'm on the right track, and if my glasses can be made to work in linux.


Sun Jul 17, 2011 8:31 am
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
I've never seen this type of glasses, looks more like an HMD than 3D glasses to me. If nothing is written in the manual about VGA DDC I guess they aren't compatible with it. I don't know how these glasses work in 3D mode either, if they don't use page flipping then Genlock would be basically useless. You need to have more info about these glasses, ie. about VGA DDC and page flipping support.


Sun Jul 17, 2011 12:28 pm
Profile WWW
3D Angel Eyes (Moderator)
User avatar

Joined: Sat Apr 12, 2008 8:18 pm
Posts: 11394
Reply with quote
I don't know that specifc HMD, but most of those generic headsets were designed to work with the old Nvidia driver in VGA DDC mode, so they should work identical to shutter glasses on a CRT from a software standpoint.

_________________
check my blog - cybereality.com


Sun Jul 17, 2011 1:27 pm
Profile
One Eyed Hopeful

Joined: Sat Jul 16, 2011 8:46 am
Posts: 5
Reply with quote
Aahhh..something dawns on me now. The glasses you're working on are 'dumb' devices, in that they use the real computer monitor and using shutters in each eye to block the other image. Like the shutter glasses in the cinema. Yeah, mine is indeed absolutely different, in that it is indeed a HMD with 2 individual LCD screens, one for each eye. There was support for this in the nvidia windows drivers ('Consumer Stereo 3D', 'stereo API') for a few years until they dropped it around 2008.

So, maybe you can help me figure out how to 'reverse-engineer' my glasses. I do know that the HMD uses the DDC signal to display different images to each LCD screen. How exactly do your shutterglasses use DDC? Does it involve an adapter that you plug in between the vga port on the card and the monitor cable, so that it can sniff the ddc signal? The HMD works on 60Hz only, and in 3D mode it will use half the framerate as the images have to be divided over both eyes.

Let's assume I want an identical setup, where I use a double virtual display resolution in X. How would this be different from the shutter glasses? The differences I can think of:

  • the HMD is both monitor and sync signal receiver in one. Shouldn't matter.
  • it only works on 60Hz (not 120Hz), e.g. in 3d mode you only get 30Hz for each eye.
  • The 3d mode may need to be activated or deactivated, presumably using the DDC signal? In Windows you have to toggle it manually, or it can detect it automatically (never used that). And it's only connected using VGA, USB is power only.
  • I assume it would receive the exact same DDC sync signal as it does for the shutter glasses, but that's just a guess..

I found some references:

This talks about 'field sequential vga', used by an HMD that works exactly the same (i-Visor FX601)

http://forum.iz3d.com/viewtopic.php?t=7 ... ential+vga

Here's someone who rants about the nvidia 'Consumer Stereo 3D' implementation, which was the official name, but nothing low-level in here:

http://www.mail-archive.com/osg-users@l ... 18225.html

This page shows the windows driver settings, and below it explains how it works:

http://www.worldviz.com/vizhelp/Frame_sequential.htm

So looks like page flipping + VGA DDC would be the way to go here as well, but how would I find out how to activate the 3D mode? I do still have a working windows XP setup with working 3D stereo drivers that I could perhaps use to sniff the protocol?


Sun Jul 17, 2011 2:13 pm
Profile
3D Angel Eyes (Moderator)
User avatar

Joined: Sat Apr 12, 2008 8:18 pm
Posts: 11394
Reply with quote
For the old Nvidia driver, you would use DDC VGA Glasses (I/O Display) which is the same mode used by shutter glasses. As far as I know, it works exactly the same as a CRT running at 60Hz using shutter glasses. This, however, assumes the HMD you have supports frame-sequential 3D (most did). But I think there were some that worked differently (field-sequential, etc.)

_________________
check my blog - cybereality.com


Sun Jul 17, 2011 2:30 pm
Profile
One Eyed Hopeful

Joined: Sat Jul 16, 2011 8:46 am
Posts: 5
Reply with quote
Right..so what fredz wrote is exactly what I need too, then? I think this is frame-sequential (no interlacing nastiness).

E.g. the genlock module should work with the double horizontal resolution set in the visual mode.

I got the module to compile, with some warnings that do seem troubling:

Code:
/home/brama/src/genlock-20100615/genlock.c: In function ‘sgl_nv_init’:
/home/brama/src/genlock-20100615/genlock.c:438: warning: passing argument 1 of ‘readl’ makes pointer from integer without a cast
/home/brama/src/genlock-20100615/genlock.c:438: warning: passing argument 2 of ‘writel’ makes pointer from integer without a cast
/home/brama/src/genlock-20100615/genlock.c: In function ‘sgl_nv_getpixelclock’:
/home/brama/src/genlock-20100615/genlock.c:444: warning: passing argument 1 of ‘readl’ makes pointer from integer without a cast
/home/brama/src/genlock-20100615/genlock.c: In function ‘sgl_nv_setpixelclock’:
/home/brama/src/genlock-20100615/genlock.c:449: warning: passing argument 2 of ‘writel’ makes pointer from integer without a cast
/home/brama/src/genlock-20100615/genlock.c: In function ‘init_genlock’:
/home/brama/src/genlock-20100615/genlock.c:1561: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type
/home/brama/src/genlock-20100615/genlock.c:1596: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type
/home/brama/src/genlock-20100615/genlock.c: At top level:
/home/brama/src/genlock-20100615/genlock.c:453: warning: ‘sgl_nv_calcpixelclock’ defined but not used
/home/brama/src/genlock-20100615/genlock.c:522: warning: ‘vga_wait_vn’ defined but not used


Just going ahead and inserting the module gives a kernel oops:

Code:
[ 8583.426646] Call Trace:
[ 8583.426661]  [<f7c6bb96>] ? init_genlock+0x25/0x612 [genlock]
[ 8583.426674]  [<f7c6bb71>] ? init_genlock+0x0/0x612 [genlock]
[ 8583.426683]  [<c100113e>] ? do_one_initcall+0x55/0x155
[ 8583.426691]  [<c105787d>] ? sys_init_module+0xa7/0x1d7
[ 8583.426699]  [<c10030fb>] ? sysenter_do_call+0x12/0x28
[ 8583.426703] Code: 74 0e ff 37 68 da 07 32 c1 e8 79 92 0b 00 5e 5d 8b 47 04 8b 17 8b 40 30 8b 40 34 e8 50 2c f8 ff 85 c0 74 24 8b 40 4c 85 c0 74 1d <8b> 40 30 bd f0 ff ff ff e8 30 2b f8 ff ff 37 68 17 08 32 c1 e8
[ 8583.426759] EIP: [<c11b393f>] driver_register+0x63/0xe0 SS:ESP 0068:f58b3f64
[ 8583.426769] CR2: 00000000f7c62fc0
[ 8583.426774] ---[ end trace 09e6cece3b164e21 ]---


I used a fresh debian squeeze install with stock kernel: Linux stereo 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux

(edit)

More detailed information:

First time I try to insert the module I get:

Code:

root@stereo:~# modprobe genlock
FATAL: Error inserting genlock (/lib/modules/2.6.32-5-686/misc/genlock.ko): Kernel does not have module support



Which is false, probably a messy exit status of the module code. Dmesg says:

Code:

[  232.515406] genlock: loading
[  232.515449] genlock: register parport via PnP
[  232.515851] IRQ 16/genlock: IRQF_DISABLED is not guaranteed on shared IRQs
[  232.515858] genlock: unable to get Nvidia IRQ 16 (errno=-38).


A second modprobe attempt gives the oops, and leaves the system with an unremovable genlock module.


Sun Jul 17, 2011 2:47 pm
Profile
One Eyed Hopeful

Joined: Sat Jul 16, 2011 8:46 am
Posts: 5
Reply with quote
Progress!

I inspected the source, found that there were a bunch of module parameters, and fixed the irq problem. I removed all the lp/parport/ppdev/* modules (still necessary?), and then inserted the module:

Code:
sudo modprobe genlock ddc_stereo=1 lp_genlock=0 lp_stereo=0 sharedirq=0 rightoffset=1024 pageflip=1 nv_irq=18 debug=3


This now works, and when enabling stereo mode throug the /proc interface, I get a flickering screen. E.g. it's alternating the left and right half of the virtual display using pageflip.

Where do I go from here to fix it such that it actually displays the images on left or right eye? Is some activation of the device required other than the DDC signal already being fired? Is the module hardcoded to work on 120Hz (while I run it at 60Hz)?

Dmesg output from the last attempt:

Code:
When loading:

[ 8692.716785] genlock: register parport via PnP
[ 8692.716795] IRQ 18/genlock: IRQF_DISABLED is not guaranteed on shared IRQs
[ 8692.717219] genlock: successfully registered nv_interrupt
[ 8692.717226] IRQ 7/genlock: IRQF_DISABLED is not guaranteed on shared IRQs
[ 8692.717245] genlock: successfully registered lp_interrupt

While stereo mode is active lots of:

[ 8877.050573] genlock: diff between adjust and vnend=94 us
[ 8877.066537] genlock: drift 1966470576 too large -- ignoring
[ 8877.067291] genlock: diff between adjust and vnend=93 us
[ 8877.083254] genlock: drift 1966487293 too large -- ignoring
[ 8877.084008] genlock: diff between adjust and vnend=95 us
[ 8877.099988] genlock: drift 1966504024 too large -- ignoring
[ 8877.100727] genlock: diff between adjust and vnend=93 us
[ 8877.116712] genlock: drift 1966520746 too large -- ignoring
[ 8877.133422] genlock: drift 1966537458 too large -- ignoring
[ 8877.150150] genlock: drift 1966554185 too large -- ignoring
[ 8877.166853] genlock: drift 1966570890 too large -- ignoring


Mon Jul 18, 2011 3:14 pm
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
Now you need to incorporate the code for VGA DDC I showed in another thread. I was too lazy to do it myself, if you do it don't hesitate to post a modified version of Genlock in this thread. If you are blocked at some point I may be able to help, I should have some test source code left on my Linux hard disk when I was playing with VGA DDC.


Mon Jul 18, 2011 3:57 pm
Profile WWW
One Eyed Hopeful

Joined: Sat Jul 16, 2011 8:46 am
Posts: 5
Reply with quote
Are you referring to the lines you added to nvclock? E.g. replace the contents of ddc_set_stereo_state with the toggle from there? Yeah, I'll give that a try. I'll let you know how that turns out.


Tue Jul 19, 2011 1:45 pm
Profile
One Eyed Hopeful

Joined: Mon Apr 07, 2008 5:47 pm
Posts: 26
Reply with quote
Hi Stragulus,

It is crazy to think that you only posted two months ago compared to most discussions on this dating back four years ago. I hope you are still checking this forum.
Anyways I compiled the genlock version and got similar warnings. Here is the results. If you would not mind uploading your fixes, I woud appreciate it. I am running Centos with kernel 2.6.18-238.19.1.el5-x86_64. I will upgrade to a better Kernel once 6.1 arrives.
Code:
[root@localhost genlock-20100615]# make
make -C /lib/modules/2.6.18-238.19.1.el5/build SUBDIRS=/tmp/genlock-20100615 modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-238.19.1.el5-x86_64'
  CC [M]  /tmp/genlock-20100615/genlock.o
/tmp/genlock-20100615/genlock.c: In function ‘sgl_ioremap’:
/tmp/genlock-20100615/genlock.c:378: warning: format ‘%x’ expects type ‘unsigned int’, but argument 4 has type ‘resource_size_t’
/tmp/genlock-20100615/genlock.c:378: warning: format ‘%x’ expects type ‘unsigned int’, but argument 5 has type ‘resource_size_t’
/tmp/genlock-20100615/genlock.c:397: warning: format ‘%x’ expects type ‘unsigned int’, but argument 3 has type ‘resource_size_t’
/tmp/genlock-20100615/genlock.c:401: warning: cast from pointer to integer of different size
/tmp/genlock-20100615/genlock.c: In function ‘sgl_iounmap’:
/tmp/genlock-20100615/genlock.c:408: warning: cast to pointer from integer of different size
/tmp/genlock-20100615/genlock.c: In function ‘sgl_nv_init’:
/tmp/genlock-20100615/genlock.c:438: warning: passing argument 1 of ‘__readl’ makes pointer from integer without a cast
/tmp/genlock-20100615/genlock.c:438: warning: passing argument 2 of ‘__writel’ makes pointer from integer without a cast
/tmp/genlock-20100615/genlock.c: In function ‘sgl_nv_getpixelclock’:
/tmp/genlock-20100615/genlock.c:444: warning: passing argument 1 of ‘__readl’ makes pointer from integer without a cast
/tmp/genlock-20100615/genlock.c: In function ‘sgl_nv_setpixelclock’:
/tmp/genlock-20100615/genlock.c:449: warning: passing argument 2 of ‘__writel’ makes pointer from integer without a cast
/tmp/genlock-20100615/genlock.c: At top level:
/tmp/genlock-20100615/genlock.c:453: warning: ‘sgl_nv_calcpixelclock’ defined but not used
/tmp/genlock-20100615/genlock.c:522: warning: ‘vga_wait_vn’ defined but not used
  Building modules, stage 2.
  MODPOST
  CC      /tmp/genlock-20100615/genlock.mod.o
  LD [M]  /tmp/genlock-20100615/genlock.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.18-238.19.1.el5-x86_64'


Wed Sep 28, 2011 9:08 am
Profile
Petrif-Eyed
User avatar

Joined: Sat Jan 09, 2010 2:06 pm
Posts: 2255
Location: Perpignan, France
Reply with quote
I don't think Stragulus made any modification to the source beside the change of the IRQ number of the graphics card.

He then removed all the modules related to the parallel port and he gave the command line he used to load the genlock module.

The warnings you are seeing while compiling shouldn't be problematic, the last lines are showing that the module has indeed been built correctly.


Sat Oct 01, 2011 9:11 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 32 posts ] 

Who is online

Users browsing this forum: Tbot and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.