# uvcvideo autoload (SOLVED)

## Apopatos

Hi guys,

I have a uvc based webcam and my problem is that:

When I boot my system the uvcvideo module is loaded automatically and the /dev/v4l/video devices are created. The webcam though does not work. If I run modprobe -r uvcvideo and then modprobe uvcvideo or if I unplug and plug it again the camera works like a charm.

Why is that? Any way to make the camera work properly without unload  and load again the module?

thanksLast edited by Apopatos on Fri May 22, 2009 6:24 pm; edited 1 time in total

----------

## Apopatos

Ok this became a serious problem, since I'm away from home most of the time and the other users (old men and young children) aren't able to pull the tower and reconnect the web-camera or play around with root privileges.

I can't believe that this thing is so difficult   :Confused: 

----------

## foxicatko

Hi.

The lamest idea, that came first into my mind is to create a script that reloads the module for you and have it executed as the last thing bofore login or the first after the login. But I'm sure there must be a more elegant way to resolve this.   :Wink: 

----------

## Apopatos

Yeah I'd prefer a more elegant idea as well, but till then I can live with that, better than nothing after all   :Smile: 

So I have to create a script which will do:

```
modprobe -r uvcvideo

modprobe uvcvideo
```

but how am I doing that (no idea how to write any kind of code) and where should I put it to be loaded automatically during boot or before login?

----------

## pigeon768

```
#!/sbin/runscript

#Put this file in /etc/init.d/uvcreload

#Then run rc-update 'add uvcreload default'

start()

{

   ebegin "Reloading uvcvideo module"

   modprobe -r uvcvideo

   modprobe uvcvideo

   eend 0

}

stop()

{

   ebegin "Unloading uvcvideo module"

   modprobe -r uvcvideo

   eend 0

}
```

----------

## Apopatos

It doesn't work   :Sad: 

I made it executable, moved it to /etc/init.d added it to runlevel and rebooted but nothing.

(when I run /etc/init.d/uvcreload stop the module is not unloaded)

----------

## Apopatos

Also, rc-status shows always uvcreload as stopped despite if I start or restart it. Is that normal?

----------

## pigeon768

Well, I'm stumped. I tried that same script with the vfat module instead of uvcvideo (I don't have a webcam) and it worked. Maybe there's typo somewhere?

What's the output of '/etc/init.d/uvcreload restart' and then '/etc/init.d/uvcreload status'?

----------

## Apopatos

I added the uvcvideo module in the blacklist to not be loaded during boot at all and your script works perfectly now   :Razz: 

Maybe the problem was to unload the module because uvcvideo loads videodev, v4l1_compat and v4l2_compat_ioctl32, weird huh? But it works now like a dream, thanks a ton pigeon768!

----------

