[cpia] I Solved all the QX3 Microscope problems (2.4up)
Sam Alexander
sam102@crpud.net
Mon, 4 Feb 2002 16:23:10 -0800
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01C1AD98.3C8B2230
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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)
[root@squid source]# tar -xvzf cpia-1.2
[root@squid source]# cd cpia-1.2/module
[root@squid module]# make
Should get these errors:
echo '# Program dependencies' >.depend
gcc -M -D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer =
-pipe=20
-fno-strength-reduce -m486 -malign-loops=3D2 -malign-jumps=3D2 =
-malign-functions=3D2 -
DCPU=3D686 -fomit-frame-pointer -fno-strength-reduce -I. =
-I/usr/src/linux/include=20
-D__KERNEL__ -DMODULE -DCONFIG_VIDEO_CPIA_MODULE =
-DCONFIG_VIDEO_CPIA_PP_MODULE -
DCONFIG_VIDEO_CPIA_PP_DMA cpia.c cpia_pp.c >>.depend
gcc -c -D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer =
-pipe=20
-fno-strength-reduce -m486 -malign-loops=3D2 -malign-jumps=3D2 =
-malign-functions=3D2 -
DCPU=3D686 -fomit-frame-pointer -fno-strength-reduce -I. =
-I/usr/src/linux/include=20
-D__KERNEL__ -DMODULE -DCONFIG_VIDEO_CPIA_MODULE =
-DCONFIG_VIDEO_CPIA_PP_MODULE -
DCONFIG_VIDEO_CPIA_PP_DMA cpia.c
cpia.c: In function `cpia_write_proc':
cpia.c:652: warning: `val' might be used uninitialized in this function
cpia.c: At top level:
cpia.c:3906: warning: initialization from incompatible pointer type
cpia.c:3907: warning: missing braces around initializer
cpia.c:3907: warning: (near initialization for `cpia_template.name')
cpia.c:3909: warning: initialization makes integer from pointer without =
a cast
cpia.c:3909: initializer element is not computable at load time
cpia.c:3909: (near initialization for `cpia_template.name[2]')
cpia.c:3910: warning: initialization makes integer from pointer without =
a cast
cpia.c:3910: initializer element is not computable at load time
cpia.c:3910: (near initialization for `cpia_template.name[3]')
cpia.c:3911: warning: initialization makes integer from pointer without =
a cast
cpia.c:3911: initializer element is not computable at load time
cpia.c:3911: (near initialization for `cpia_template.name[4]')
cpia.c:3912: warning: initialization makes integer from pointer without =
a cast
cpia.c:3913: warning: initialization makes integer from pointer without =
a cast
cpia.c:3914: warning: initialization makes integer from pointer without =
a cast
cpia.c:3914: initializer element is not computable at load time
cpia.c:3914: (near initialization for `cpia_template.name[7]')
cpia.c:3915: warning: initialization makes integer from pointer without =
a cast
cpia.c:3915: initializer element is not computable at load time
cpia.c:3915: (near initialization for `cpia_template.name[8]')
cpia.c:3916: warning: initialization makes integer from pointer without =
a cast
cpia.c:3916: initializer element is not computable at load time
cpia.c:3916: (near initialization for `cpia_template.name[9]')
cpia.c:3917: warning: initialization makes integer from pointer without =
a cast
cpia.c: In function `cpia_register_camera':
cpia.c:4079: too few arguments to function `video_register_device'
make: *** [cpia.o] Error 1
After a few hours research I managed to edit the source so that it will =
compile with out error!=20
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)
All other programs that create video_device structures have the first =
argument THIS_MODULE, except for cpia.c
Simply follow these steps to fix that:
[root@squid module]# pico cpia.c
Change this:
static struct video_device cpia_template =3D {
"CPiA Camera",
VID_TYPE_CAPTURE,
VID_HARDWARE_CPIA,
cpia_open, /* open */
cpia_close, /* close */
cpia_read, /* read */
NULL, /* no write */
NULL, /* no poll */
cpia_ioctl, /* ioctl */
cpia_mmap, /* mmap */
cpia_video_init, /* initialize */
NULL, /* priv */
0, /* busy */
-1 /* minor - unset */
};
To this:
static struct video_device cpia_template =3D {
THIS_MODULE,
"CPiA Camera",
VID_TYPE_CAPTURE,
VID_HARDWARE_CPIA,
cpia_open, /* open */
cpia_close, /* close */
cpia_read, /* read */
NULL, /* no write */
NULL, /* no poll */
cpia_ioctl, /* ioctl */
cpia_mmap, /* mmap */
cpia_video_init, /* initialize */
NULL, /* priv */
0, /* busy */
-1 /* minor - unset */
};
Save and exit then remake:
[root@squid module]# make
You should get this output:
gcc -c -D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer =
-pipe -fno-strength-reduce -m486 -malign-loops=3D2 -malign-jumps=3D2 =
-malign-functions=3D2 -DCPU=3D686 -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
cpia.c: In function `cpia_write_proc':
cpia.c:652: warning: `val' might be used uninitialized in this function
cpia.c: In function `cpia_register_camera':
cpia.c:4080: too few arguments to function `video_register_device'
make: *** [cpia.o] Error 1
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:
[root@squid module]# pico cpia.c
change this:
if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER) =
=3D=3D -1) {
to this:
if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, -1) =
=3D=3D -1) {
Save exit and remake!
[root@squid module]# make
And it compiles succesfully!
Now insert the modules into the kernel!
[root@squid module]# insmod cpia.o
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:
[root@squid module]# echo "toplight: on" > /proc/cpia/video0
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.
[root@squid module]# cat /proc/cpia/video0
This command shows all readable/writeable entries in /proc/cpia/video0
Please reply because I want to know if this helps anyone! Thanks.
--Sam Alexander
------=_NextPart_000_0005_01C1AD98.3C8B2230
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2712.300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Ok, download the CVS version (currently =
1.2) of the=20
cpia driver. I am using the 2.4.7-10 (default with Red Hat linux=20
7.2)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>[root@squid source]# tar -xvzf=20
cpia-1.2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>[root@squid source]# cd=20
cpia-1.2/module</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>[root@squid module]# make</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Should get these errors:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>echo '# Program dependencies' =
>.depend<BR>gcc -M=20
-D_CPIA_DEBUG_ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer =
-pipe=20
<BR>-fno-strength-reduce -m486 -malign-loops=3D2 -malign-jumps=3D2=20
-malign-functions=3D2 -<BR>DCPU=3D686 -fomit-frame-pointer =
-fno-strength-reduce -I.=20
-I/usr/src/linux/include <BR>-D__KERNEL__ -DMODULE =
-DCONFIG_VIDEO_CPIA_MODULE=20
-DCONFIG_VIDEO_CPIA_PP_MODULE -<BR>DCONFIG_VIDEO_CPIA_PP_DMA =
cpia.c=20
cpia_pp.c >>.depend<BR>gcc -c -D_CPIA_DEBUG_ -Wall=20
-Wstrict-prototypes -O2 -fomit-frame-pointer -pipe=20
<BR>-fno-strength-reduce -m486 -malign-loops=3D2 -malign-jumps=3D2=20
-malign-functions=3D2 -<BR>DCPU=3D686 -fomit-frame-pointer =
-fno-strength-reduce -I.=20
-I/usr/src/linux/include <BR>-D__KERNEL__ -DMODULE =
-DCONFIG_VIDEO_CPIA_MODULE=20
-DCONFIG_VIDEO_CPIA_PP_MODULE -<BR>DCONFIG_VIDEO_CPIA_PP_DMA =20
cpia.c<BR>cpia.c: In function `cpia_write_proc':<BR>cpia.c:652: warning: =
`val'=20
might be used uninitialized in this function<BR>cpia.c: At top=20
level:<BR>cpia.c:3906: warning: initialization from incompatible pointer =
type<BR>cpia.c:3907: warning: missing braces around =
initializer<BR>cpia.c:3907:=20
warning: (near initialization for `cpia_template.name')<BR>cpia.c:3909: =
warning:=20
initialization makes integer from pointer without a cast<BR>cpia.c:3909: =
initializer element is not computable at load time<BR>cpia.c:3909: (near =
initialization for `cpia_template.name[2]')<BR>cpia.c:3910: warning:=20
initialization makes integer from pointer without a cast<BR>cpia.c:3910: =
initializer element is not computable at load time<BR>cpia.c:3910: (near =
initialization for `cpia_template.name[3]')<BR>cpia.c:3911: warning:=20
initialization makes integer from pointer without a cast<BR>cpia.c:3911: =
initializer element is not computable at load time<BR>cpia.c:3911: (near =
initialization for `cpia_template.name[4]')<BR>cpia.c:3912: warning:=20
initialization makes integer from pointer without a cast<BR>cpia.c:3913: =
warning: initialization makes integer from pointer without a=20
cast<BR>cpia.c:3914: warning: initialization makes integer from pointer =
without=20
a cast<BR>cpia.c:3914: initializer element is not computable at load=20
time<BR>cpia.c:3914: (near initialization for=20
`cpia_template.name[7]')<BR>cpia.c:3915: warning: initialization makes =
integer=20
from pointer without a cast<BR>cpia.c:3915: initializer element is not=20
computable at load time<BR>cpia.c:3915: (near initialization for=20
`cpia_template.name[8]')<BR>cpia.c:3916: warning: initialization makes =
integer=20
from pointer without a cast<BR>cpia.c:3916: initializer element is not=20
computable at load time<BR>cpia.c:3916: (near initialization for=20
`cpia_template.name[9]')<BR>cpia.c:3917: warning: initialization makes =
integer=20
from pointer without a cast<BR>cpia.c: In function=20
`cpia_register_camera':<BR>cpia.c:4079: too few arguments to function=20
`video_register_device'<BR>make: *** [cpia.o] Error 1<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>After a few hours research I managed to =
edit the=20
source so that it will compile with out error! </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>The problem is that cpia.c attempts to =
create a=20
video_device structure which is missing the first argument, which in =
turn throws=20
off all proceeding values (explains errors on lines 3906 through=20
3917)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>All other programs that create =
video_device=20
structures have the first argument THIS_MODULE, except for =
cpia.c</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Simply follow these steps to fix =
that:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>[root@squid module]# pico =
cpia.c</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Change this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>static struct video_device =
cpia_template =3D=20
{<BR> "CPiA=20
Camera",<BR> =20
VID_TYPE_CAPTURE,<BR> =20
VID_HARDWARE_CPIA,<BR> =20
cpia_open, &nb=
sp; =20
/* open */<BR> =20
cpia_close, &n=
bsp; =20
/* close */<BR> =20
cpia_read, &nb=
sp; =20
/* read */<BR> =20
NULL, &n=
bsp; =20
/* no write */<BR> =20
NULL, &n=
bsp; =20
/* no poll */<BR> =20
cpia_ioctl, &n=
bsp; =20
/* ioctl */<BR> =20
cpia_mmap, &nb=
sp; =20
/* mmap */<BR> =20
cpia_video_init, /* initialize =
*/<BR> =20
NULL, &n=
bsp; =20
/* priv */<BR> =20
0,  =
; =20
/* busy */<BR> =20
-1  =
; =20
/* minor - unset */<BR>};</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>To this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>static struct video_device =
cpia_template =3D=20
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
THIS_MODULE,<BR> "CPiA=20
Camera",<BR> =20
VID_TYPE_CAPTURE,<BR> =20
VID_HARDWARE_CPIA,<BR> =20
cpia_open, &nb=
sp; =20
/* open */<BR> =20
cpia_close, &n=
bsp; =20
/* close */<BR> =20
cpia_read, &nb=
sp; =20
/* read */<BR> =20
NULL, &n=
bsp; =20
/* no write */<BR> =20
NULL, &n=
bsp; =20
/* no poll */<BR> =20
cpia_ioctl, &n=
bsp; =20
/* ioctl */<BR> =20
cpia_mmap, &nb=
sp; =20
/* mmap */<BR> =20
cpia_video_init, /* initialize =
*/<BR> =20
NULL, &n=
bsp; =20
/* priv */<BR> =20
0,  =
; =20
/* busy */<BR> =20
-1  =
; =20
/* minor - unset */<BR>};</DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>Save and exit then remake:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>[root@squid module]# make</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>You should get this =
output:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>gcc -c -D_CPIA_DEBUG_ -Wall =
-Wstrict-prototypes -O2=20
-fomit-frame-pointer -pipe -fno-strength-reduce -m486 =
-malign-loops=3D2=20
-malign-jumps=3D2 -malign-functions=3D2 -DCPU=3D686 -fomit-frame-pointer =
-fno-strength-reduce -I. -I/usr/src/linux/include -D__KERNEL__ -DMODULE=20
-DCONFIG_VIDEO_CPIA_MODULE -DCONFIG_VIDEO_CPIA_PP_MODULE=20
-DCONFIG_VIDEO_CPIA_PP_DMA cpia.c<BR>cpia.c: In function=20
`cpia_write_proc':<BR>cpia.c:652: warning: `val' might be used =
uninitialized in=20
this function<BR>cpia.c: In function =
`cpia_register_camera':<BR>cpia.c:4080: too=20
few arguments to function `video_register_device'<BR>make: *** [cpia.o] =
Error=20
1<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Aha!! quite a few less errors hm? It =
seems that the=20
call to video_register_device requires three values and not two, like in =
cpia.c.=20
I worked through some more source and found that it requires the third =
argument=20
video_nr, which most modules use the value "-1". I'm not sure about this =
but it=20
works fine, you might want to see what video_nr actually means, but =
every source=20
file I found used the value -1. To fix this:</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>[root@squid module]# pico=20
cpia.c</FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>change this:</FONT></FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> if=20
(video_register_device(&camera->vdev, VFL_TYPE_GRABBER) =3D=3D =
-1)=20
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>to this:</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> if=20
(video_register_device(&camera->vdev, VFL_TYPE_GRABBER, -1) =
=3D=3D -1)=20
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Save exit and remake!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>[root@squid module]# make</DIV>
<DIV>And it compiles succesfully!</DIV>
<DIV>Now insert the modules into the kernel!<BR></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=20
new cpia driver! That's it! Then you can use the proc interface... for=20
example:</DIV>
<DIV>[root@squid module]# echo "toplight: on" > =
/proc/cpia/video0</DIV>
<DIV>For some reason this only works if gqcam is running... hm need to =
fix that,=20
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=20
/proc/cpia/video0</DIV>
<DIV> </DIV>
<DIV>Please reply because I want to know if this helps anyone!=20
Thanks.</DIV></FONT>
<DIV><FONT face=3DArial><FONT size=3D2></FONT> </DIV></FONT>
<DIV><FONT face=3DArial size=3D2>--Sam =
Alexander</FONT></DIV></BODY></HTML>
------=_NextPart_000_0005_01C1AD98.3C8B2230--