[cpia] I Solved all the QX3 Microscope problems (2.4up) Fixed!!!

Sam Alexander sama102@hotmail.com
Mon, 04 Feb 2002 16:28:03 -0800


<html><div style='background-color:'><DIV>Ok, download the CVS version (currently 1.2) of the cpia driver. I am using the 2.4.7-10 (default with Red Hat linux 7.2) </DIV>
<DIV></DIV>[root@squid source]# tar -xvzf cpia-1.2 
<DIV></DIV>[root@squid source]# cd cpia-1.2/module 
<DIV></DIV>[root@squid module]# make 
<DIV></DIV>Should get these errors: 
<DIV></DIV>
<DIV></DIV>echo '# Program dependencies' &gt;.depend 
<DIV></DIV>gcc -M -D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe 
<DIV></DIV>-fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 - 
<DIV></DIV>DCPU=686 -fomit-frame-pointer -fno-strength-reduce -I. -I/usr/src/linux/include 
<DIV></DIV>-D__KERNEL__ -DMODULE -DCONFIG_VIDEO_CPIA_MODULE -DCONFIG_VIDEO_CPIA_PP_MODULE - 
<DIV></DIV>DCONFIG_VIDEO_CPIA_PP_DMA cpia.c cpia_pp.c &gt;&gt;.depend 
<DIV></DIV>gcc -c -D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe 
<DIV></DIV>-fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 - 
<DIV></DIV>DCPU=686 -fomit-frame-pointer -fno-strength-reduce -I. -I/usr/src/linux/include 
<DIV></DIV>-D__KERNEL__ -DMODULE -DCONFIG_VIDEO_CPIA_MODULE -DCONFIG_VIDEO_CPIA_PP_MODULE - 
<DIV></DIV>DCONFIG_VIDEO_CPIA_PP_DMA cpia.c 
<DIV></DIV>cpia.c: In function `cpia_write_proc': 
<DIV></DIV>cpia.c:652: warning: `val' might be used uninitialized in this function 
<DIV></DIV>cpia.c: At top level: 
<DIV></DIV>cpia.c:3906: warning: initialization from incompatible pointer type 
<DIV></DIV>cpia.c:3907: warning: missing braces around initializer 
<DIV></DIV>cpia.c:3907: warning: (near initialization for `cpia_template.name') 
<DIV></DIV>cpia.c:3909: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3909: initializer element is not computable at load time 
<DIV></DIV>cpia.c:3909: (near initialization for `cpia_template.name[2]') 
<DIV></DIV>cpia.c:3910: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3910: initializer element is not computable at load time 
<DIV></DIV>cpia.c:3910: (near initialization for `cpia_template.name[3]') 
<DIV></DIV>cpia.c:3911: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3911: initializer element is not computable at load time 
<DIV></DIV>cpia.c:3911: (near initialization for `cpia_template.name[4]') 
<DIV></DIV>cpia.c:3912: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3913: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3914: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3914: initializer element is not computable at load time 
<DIV></DIV>cpia.c:3914: (near initialization for `cpia_template.name[7]') 
<DIV></DIV>cpia.c:3915: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3915: initializer element is not computable at load time 
<DIV></DIV>cpia.c:3915: (near initialization for `cpia_template.name[8]') 
<DIV></DIV>cpia.c:3916: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c:3916: initializer element is not computable at load time 
<DIV></DIV>cpia.c:3916: (near initialization for `cpia_template.name[9]') 
<DIV></DIV>cpia.c:3917: warning: initialization makes integer from pointer without a cast 
<DIV></DIV>cpia.c: In function `cpia_register_camera': 
<DIV></DIV>cpia.c:4079: too few arguments to function `video_register_device' 
<DIV></DIV>make: *** [cpia.o] Error 1 
<DIV></DIV>
<DIV></DIV>After a few hours research I managed to edit the source so that it will compile with out error! 
<DIV></DIV>The problem is that cpia.c attempts to create a video_device structure which is missing the first argument, which in turn throws off all proceeding values (explains errors on lines 3906 through 3917) 
<DIV></DIV>All other programs that create video_device structures have the first argument THIS_MODULE, except for cpia.c 
<DIV></DIV>Simply follow these steps to fix that: 
<DIV></DIV>[root@squid module]# pico cpia.c 
<DIV></DIV>
<DIV></DIV>Change this: 
<DIV></DIV>static struct video_device cpia_template = { 
<DIV></DIV>"CPiA Camera", 
<DIV></DIV>VID_TYPE_CAPTURE, 
<DIV></DIV>VID_HARDWARE_CPIA, 
<DIV></DIV>cpia_open, /* open */ 
<DIV></DIV>cpia_close, /* close */ 
<DIV></DIV>cpia_read, /* read */ 
<DIV></DIV>NULL, /* no write */ 
<DIV></DIV>NULL, /* no poll */ 
<DIV></DIV>cpia_ioctl, /* ioctl */ 
<DIV></DIV>cpia_mmap, /* mmap */ 
<DIV></DIV>cpia_video_init, /* initialize */ 
<DIV></DIV>NULL, /* priv */ 
<DIV></DIV>0, /* busy */ 
<DIV></DIV>-1 /* minor - unset */ 
<DIV></DIV>}; 
<DIV></DIV>
<DIV></DIV>To this: 
<DIV></DIV>static struct video_device cpia_template = { 
<DIV></DIV>THIS_MODULE, 
<DIV></DIV>"CPiA Camera", 
<DIV></DIV>VID_TYPE_CAPTURE, 
<DIV></DIV>VID_HARDWARE_CPIA, 
<DIV></DIV>cpia_open, /* open */ 
<DIV></DIV>cpia_close, /* close */ 
<DIV></DIV>cpia_read, /* read */ 
<DIV></DIV>NULL, /* no write */ 
<DIV></DIV>NULL, /* no poll */ 
<DIV></DIV>cpia_ioctl, /* ioctl */ 
<DIV></DIV>cpia_mmap, /* mmap */ 
<DIV></DIV>cpia_video_init, /* initialize */ 
<DIV></DIV>NULL, /* priv */ 
<DIV></DIV>0, /* busy */ 
<DIV></DIV>-1 /* minor - unset */ 
<DIV></DIV>}; 
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>Save and exit then remake: 
<DIV></DIV>[root@squid module]# make 
<DIV></DIV>You should get this output: 
<DIV></DIV>
<DIV></DIV>gcc -c -D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=686 -fomit-frame-pointer -fno-strength-reduce -I. -I/usr/src/linux/include -D__KERNEL__ -DMODULE -DCONFIG_VIDEO_CPIA_MODULE -DCONFIG_VIDEO_CPIA_PP_MODULE -DCONFIG_VIDEO_CPIA_PP_DMA cpia.c 
<DIV></DIV>cpia.c: In function `cpia_write_proc': 
<DIV></DIV>cpia.c:652: warning: `val' might be used uninitialized in this function 
<DIV></DIV>cpia.c: In function `cpia_register_camera': 
<DIV></DIV>cpia.c:4080: too few arguments to function `video_register_device' 
<DIV></DIV>make: *** [cpia.o] Error 1 
<DIV></DIV>
<DIV></DIV>Aha!! quite a few less errors hm? It seems that the call to video_register_device requires three values and not two, like in cpia.c. I worked through some more source and found that it requires the third argument video_nr, which most modules use the value "-1". I'm not sure about this but it works fine, you might want to see what video_nr actually means, but every source file I found used the value -1. To fix this: 
<DIV></DIV>[root@squid module]# pico cpia.c 
<DIV></DIV>change this: 
<DIV></DIV>if (video_register_device(&amp;camera-&gt;vdev, VFL_TYPE_GRABBER) == -1) { 
<DIV></DIV>to this: 
<DIV></DIV>if (video_register_device(&amp;camera-&gt;vdev, VFL_TYPE_GRABBER, -1) == -1) { 
<DIV></DIV>
<DIV></DIV>Save exit and remake! 
<DIV></DIV>[root@squid module]# make 
<DIV></DIV>And it compiles succesfully! 
<DIV></DIV>Now insert the modules into the kernel! 
<DIV></DIV>
<DIV></DIV>[root@squid module]# insmod cpia.o 
<DIV></DIV>Using the old cpia_usb.o and old videodev.o modules will work fine with the new cpia driver! That's it! Then you can use the proc interface... for example: 
<DIV></DIV>[root@squid module]# echo "toplight: on" &gt; /proc/cpia/video0 
<DIV></DIV>For some reason this only works if gqcam is running... hm need to fix that, probly has to do something with it being on standby or something. 
<DIV></DIV>[root@squid module]# cat /proc/cpia/video0 
<DIV></DIV>This command shows all readable/writeable entries in /proc/cpia/video0 
<DIV></DIV>
<DIV></DIV>Please reply because I want to know if this helps anyone! Thanks. 
<DIV></DIV>
<DIV></DIV>--Sam Alexander</div><br clear=all><hr>Join the world’s largest e-mail service with MSN Hotmail. <a href='http://go.msn.com/bql/hmtag4_etl_EN.asp'>Click Here</a><br></html>