[cpia] USB anyone?

sbertin@mindspring.com sbertin@mindspring.com
Mon, 17 Jan 2000 22:04:44 -0500 (EST)


On 17 Jan, Jochen Scharrlach wrote:
> There is one thing I still don't understand: video_register_device()
> is called in cpia_register_camera(), while video_unregister_device()
> is called by cpia_close()

That call is redundant (maybe) and will only occur if the the camera is
open when cpia_unregister_camera is called. cam->ops will only be NULL
if the camera was removed.  See the FIXME comment in
cpia_unregister_camera.  This either needs to be made conditional on
cam->open_count == 0 or removed from cpia_close.  Until this can be
tested with a USB camera I can't tell which is correct.  Having it
called twice is clearly wrong though.

> It seems to take some time until I understand the driver. Sorry, it
> *is* be possible to use your scheme, but I have to admit that I don't
> like it: there are two more or less redundant fixed-size arrays to
> keep track of the cameras. So I'll take this problem in two steps:
> first I'll make a driver that works with the current cpia.c and then
> I'll try to convince you to change the array-stuff...

Feel free to get rid of the array stuff if you have a better solution. I
had briefly eliminated the arrays, but the code became more complex and
I didn't think it was worth saving the space of 8 pointers, so I put it
back.

> The theory: the highlevel cpia.c either gets called by the
> lowlevel-driver to (un)register a camera or it is called by the
> v4l-API to do something with an existing driver - I don't think it's
> ever needed that the cpia.c tells the lowlevel-driver to (un)register
>  camera, assuming that it is not possible to unload cpia.o *before* 
> cpia_*.o (which wouldn't make sense IMHO). So only the 
> lowlevel-drivers have to keep track of the cameras and no camera[] and 
> camnr's are needed by cpia.c. The lowlevel-drivers could use a linked 
> list for this. The following could be in cpia.h (keep in mind that my 
> C is a bit rusty):

That's correct, but imcomplete.  The problem case is where the camera is
removed when it is open.  The low level driver should get rid of its
information about the camera, but the higher level still needs some
information until close is called.  I don't want to discourge you, but
keep this case in mind as you design something to replace the existing
system.

Scott J. Bertin
sbertin@mindspring.com