# webcamd / VIDIOCGCAP / skype



## pprocacci (Jun 4, 2010)

So, given the thread listed here:

http://forums.freebsd.org/showthread.php?t=11642

I've decided to give FreeBSD a try on the desktop.  My goal, get the a) webcam b) skype and c) wine working on amd64.

Do to webcamd, my webcam works fine.  However, getting skype to work with it isn't nearly as easy.

When going into the options for skype, I'm presented with the following error in /var/log/messages:


```
Jun  3 23:29:39 wm kernel: linux: pid 49246 (skype): ioctl fd=18, cmd=0x7601 ('v',1) is not implemented
```

Some snooping has let me to VIDIOCGCAP (or lack thereof) being available via linux.ko.  This post specifically points this out:

http://www.mail-archive.com/freebsd-usb@freebsd.org/msg06354.html

I know developers and other talent frequent these forums.  It's my hope that someone more familiar with the linux ioctl's can at the very least point me in the right direction.  It would be great if a patch is already available and hasn't been commited yet or something along those lines.  ;P

#####################
UPDATE
#####################

I am now able to get skype to see the /dev/video0 device by way of upgrading to -CURRENT.  This was suggested by Alexander on the freebsd-emulation mailing list.  The good news is that skype now sees the device, however accessing it still has it's problems.  webcamd is now acting up horribly as shown here:


```
8816 root          6  44  r0F 32512K  3812K CPU2    0   3:32 200.00% webcamd
```

I will be contacting the author to see what he (hans) has to say.  Hopefully I can get further updates.  I will post them here.

Edit:  I should mention I am running the latest webcamd and cuse4bsd.


#####################
UPDATE
#####################

After spending this afternoon with Hans in irc, he determined that "my cpu is too fast" and there was a race condition in the webcamd port.  After applying several modifications to linux_usb.c the spinning that webcamd was doing has stopped.  Here is a patch file that I've created showing the diffs:


```
wm# diff -u linux_usb.c.orig linux_usb.c
--- linux_usb.c.orig    2010-06-04 16:18:22.000000000 -0500
+++ linux_usb.c 2010-06-04 16:27:50.000000000 -0500
@@ -199,18 +199,28 @@
 usb_linux_create_event_thread(struct usb_device *dev)
 {
        struct usb_linux_softc *sc = dev->parent;
+       uint32_t drops;
 
        sc->thread_started = 0;
        sc->thread_stopping = 0;
 
+         atomic_lock();
+         drops = atomic_drop();
+         atomic_unlock();
+
        /* start USB event thread again */
        if (pthread_create(&sc->thread, NULL,
            usb_exec, sc)) {
                printf("Failed creating USB process\n");
        } else {
                while (sc->thread_started == 0)
-                       pthread_yield();
+                       usleep(1000);
        }
+
+         atomic_lock();
+         atomic_pickup(drops);
+         atomic_unlock();
+
 }
 
 struct usb_linux_softc *
@@ -1393,7 +1403,7 @@
        while (sc->thread_started != 0) {
                sc->thread_stopping = 1;
                pthread_kill(sc->thread, SIGHUP);
-               pthread_yield();
+               usleep(1000);
        }
 
        atomic_lock();
```

Please note this may or may not be the "offical" patch going into the new build, but "it works for me!".  Skype still doesn't work, but webcamd starts reliably now.  Onto more debugging of skype!


----------



## hselasky@ (Jun 4, 2010)

Hi,

Webcamd has been updated to version 0.1.14 incorporating a fix for this issue.

See:

http://www.freshports.org/multimedia/webcamd/

Thanks for testing!

--HPS


----------

