TO INSTALL

Do a 
	make cortex.o
then become root and do a 
	make install
then add a a line like:
   	alias char-major-63 cortex
to your conf.modules or modules.conf file.

Ok thats it. Now try it out by doing a capture with
Try to do a capture with 

cat /dev/cortex.pgm > /tmp/foo.pgm 

then display /tmp/foo.pgm with something like 
xv /tmp/foo.pgm

if this fails, check that you have a video camera turned on and connect to
the card. It will fail if there is not video source.

try making the other programs in directory with 

make 


TROUBLESHOOTING

You can set the port and memory location of your card with a command like.

/sbin/insmod cortex cortex_port=0x230 cortex_mem=0xD0000

If you have set the dip switches to move your card to a different port or
base memory location change this line. I REALLY recommend not putting the
memory location at 0xA0000 because it *can* conflict with your graphics
card.  you can put this in your rc.local file if you want

if you want to get debugging, instead do

/sbin/insmod cortex cortex_port=0x230 cortex_mem=0xD000 cortex_debug=3

if you want to assign the major device number to 50, instead do
/sbin/insmod cortex cortex_port=0x230 cortex_mem=0xD000 cortex_major=50

check this worked by doing a 

lsmod

you should see a module called cortex



find out what major device it was installed as by doing a
 
cat /proc/devices 

you should see a line with a number from 1 to 63 then cortex. The number is
the major device number assigned to the driver. The makefile assumes the
device is at 63 from here on. Just replace 63 in my instructions with
whatever you have.

make the /dev entries with

mknod /dev/cortex c 63 0
mknod /dev/cortex.pgm c 63 1
mknod /dev/cortexSmall c 63 2
mknod /dev/cortexSmall.pgm c 63 3









USING THE DEVICE

When you open /dev/cortex, it grabs a 512 by 486 frame, as you do reads it
gets the data in 8 bit gray scale. If you just want a small part of the
frame, seek to the location you want to start reading from and get the
data. This is much faster than loading the whole frame.

When you open /dev/cortex.pgm, it grabs a frame and when you read it. It
returns data in the format of a pgm file. This is a very easy way to use
the device. I often use the command 

cat /dev/cortex.pgm | xv - 

to capture an image


There is also a /dev/cotexSmall that captures 256 by 243 pixel frames. It
is much faster as it only grabs one field of video instead of a full frame.


Some example programs are provided - have a look at ctest.c, ctest2.c and
performance.c

SETTING UP THE LEVELS IN THE LUT

Most people won't have to do this but if you want to change the contrast
and brightness of the captured image read on.

Do a capture of and image with a black and white object in it. Load this
image in a program like xv and find out what the pixels values of the
brightest white and darkest black area are. Say they were 23 for black and
175 for white. Remove current driver from kernel with 

	rmmod cortex

Then install it back in setting the black and white option with 

	insmod cortex.o cortex_black=23 cortex_white=175

Not capture another image. The white should have pixels values near 255 and
and the blacks near 0.

SETTING THE LUT FROM IN A PROGRAM

Open the device in a read/write mode. Capture image by reading as
normal. To change the lut, load the new lut values into an array of 256
char. write this array to the cortex in a singe write call. The single call
is important - if you write it one byte at a time it will not work. This
new lut will be left in the device until the device driver is reloaded or
until a new lut is loaded. Example code to load the lut to it's default
value would look something like

int fd;
int i;
char lut[256];

fd=open("/dev/cortex",O_RDWR); /* open for read and write */

for(i=0;i<256;i++)
{
   lut[i] = i; /* set up the lut mapping */
}

write( fd,lut,256 ); /* set card to use new lut in ONE write call */


By changing the values in the lut you can adjust how video voltage levels
gets mapped to pixel values. To do reverse video you would change the line

	lut[i] =i;

in the above code to 

	lut[i] = 255-i;

Good luck and please send me some email if this driver does or doesn't work
for you.

