On Fri, 2001-11-02 at 14:23, kevin wrote:
> I have a webcam module driver working fairly well, with the exception
> that if the driver is loaded before the camera is plugged in, the camera
> frequently does not initialize correctly. It seems to work nearly always
> if the camera is already plugged in when the driver is loaded; the
> camera can be unplugged and replugged and continue to work. Until I
> figure out what is causing the problem, I would like to prevent the
> driver from loading unless it detects that the camera is plugged in.
It would be preferrable if you focus on the original problem, not
on a workaround. Let alone the fact that this workaround will create
more problems... for instance, what if the camera cord is pulled out
for 1000 years and then replugged... the camera won't be responding,
right? but the driver is already in memory. The same thing if you
remove one camera and plug instead another, freshly assembled one -
this won't work either. You need to find out why the init seq doesn't
succeed, and fix that.
My guess would be that the camera needs some "warm-up" time to become
fully aware of itself. Maybe it has some reset circuit that is slow,
maybe there is internal (secondary) power supply that uses huge caps...
whatever the cause, you need to talk to the camera only when it is
ready to respond. Windows drivers are VERY patient, they retry init
for as long as tens of seconds sometimes...
I assume that your initialization is in the open() handler, right?
If so then just wait couple of seconds after you plug the camera in.
If you have initialization done in probe() then it is automatically
wrong, at very least because you are not running in freely blockable
thread.
I am also hoping that you are not reimplementing usbvideo library...
it already has most of the code you need to init the camera at the right
time.
Thanks,
Dmitri
PGP signature