Using WebCam with Syntek driver from Ubuntu
After installing Ubuntu in my old laptop, with unknown reason, embeded Webcam was not able to use.
The USB connection was okay as 'Syntek Web Cam'.
Linux kjpark-F9SG 4.2.0-34-generic #39-Ubuntu SMP Thu Mar 10 22:11:49 UTC 2016 i686 i686 i686 GNU/Linux
root@kjpark-F9SG:~/syntek/syntek/driver# lsusb
Bus 002 Device 005: ID 0bda:0116 Realtek Semiconductor Corp. RTS5116 Card Reader Controller
Bus 002 Device 003: ID 174f:6a33 Syntek Web Cam - Asus F3SA, F9J, F9S
Bus 002 Device 002: ID 05ac:12a8 Apple, Inc. iPhone5/5C/5S/6
Bus 002 Device 006: ID 05ac:12a0 Apple, Inc. iPhone 4S
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 002: ID 0b05:1712 ASUSTek Computer, Inc. BT-183 Bluetooth 2.0+EDR adapter
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
As there is no usb driver for that device, I've downloaded the code from following CVN server and tried to build it.
Out-of-tree GPL driver for stk11xx (by Martin Roos and Nicolas VIVEN) : http://sourceforge.net/projects/syntekdriver/
svn co https://syntekdriver.svn.sourceforge.net/svnroot/syntekdriver/trunk/driver/ syntekdriver
The code seems to be implemented from old linux kernel based. So, there are multiple build errors.
root@kjpark-F9SG:~/syntekdriver# make -f Makefile.standalone
make -C /lib/modules/4.2.0-34-generic/build SUBDIRS=/root/syntekdriver modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-34-generic'
CC [M] /root/syntekdriver/stk11xx-usb.o
CC [M] /root/syntekdriver/stk11xx-v4l.o
/root/syntekdriver/stk11xx-v4l.c: In function ‘v4l_stk11xx_register_video_device’:
/root/syntekdriver/stk11xx-v4l.c:1503:11: error: ‘struct video_device’ has no member named ‘parent’
dev->vdev->parent = &dev->interface->dev;
^
/root/syntekdriver/stk11xx-v4l.c: At top level:
/root/syntekdriver/stk11xx-v4l.c:1553:2: error: unknown field ‘ioctl’ specified in initializer
.ioctl = v4l_stk11xx_ioctl,
^
/root/syntekdriver/stk11xx-v4l.c:1553:11: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
.ioctl = v4l_stk11xx_ioctl,
^
/root/syntekdriver/stk11xx-v4l.c:1553:11: note: (near initialization for ‘v4l_stk11xx_fops.open’)
scripts/Makefile.build:258: recipe for target '/root/syntekdriver/stk11xx-v4l.o' failed
make[2]: *** [/root/syntekdriver/stk11xx-v4l.o] Error 1
Makefile:1398: recipe for target '_module_/root/syntekdriver' failed
make[1]: *** [_module_/root/syntekdriver] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-34-generic'
Makefile.standalone:13: recipe for target 'driver' failed
make: *** [driver] Error 2
After googling, there are some patches for that error.
https://patchwork.linuxtv.org/patch/19561/
https://patchwork.linuxtv.org/patch/18757/
Even applying the patches, there are build error from bug.h side.
root@kjpark-F9SG:~/syntek/syntek/driver# make -f Makefile.standalone
make -C /lib/modules/4.2.0-34-generic/build SUBDIRS=/root/syntek/syntek/driver modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-34-generic'
CC [M] /root/syntek/syntek/driver/stk11xx-sysfs.o
In file included from include/linux/thread_info.h:11:0,
from ./arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:64,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /root/syntek/syntek/driver/stk11xx-sysfs.c:34:
include/linux/bug.h:33:45: error: negative width in bit-field ‘<anonymous>’
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
^
include/linux/kernel.h:829:3: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
BUILD_BUG_ON_ZERO((perms) & 2) + \
^
include/linux/sysfs.h:92:12: note: in expansion of macro ‘VERIFY_OCTAL_PERMISSIONS’
.mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
^
include/linux/device.h:571:45: note: in expansion of macro ‘__ATTR’
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
^
/root/syntek/syntek/driver/stk11xx-sysfs.c:489:8: note: in expansion of macro ‘DEVICE_ATTR’
static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, show_brightness, store_brightness); /**
^
scripts/Makefile.build:258: recipe for target '/root/syntek/syntek/driver/stk11xx-sysfs.o' failed
make[2]: *** [/root/syntek/syntek/driver/stk11xx-sysfs.o] Error 1
Makefile:1398: recipe for target '_module_/root/syntek/syntek/driver' failed
make[1]: *** [_module_/root/syntek/syntek/driver] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-34-generic'
Makefile.standalone:13: recipe for target 'driver' failed
make: *** [driver] Error 2
For this build error, 'S_IRUGO | S_IWUGO' should be changed to '0660' manually.
https://github.com/torvalds/linux/commit/58f86cc89c3372d3e61d5b71e5513ec5a0b02848
https://github.com/notro/fbtft/issues/165
Now the driver is ready to roll out.
- modprobe videodev
- modprobe uvcvideo
- insmod stk11xx.ko
The modprobe is a tool to add or remove loadable kernel module (LKM). The insmod can load a module which is belong to '/lib/modules/#kernel-version'. Unlike the insmode, modeprobe supports to load available precedent modules which has the dependency.
Example of kernel modules loading realted with USB webcam
modprobe videodev
[ 4468.540163] media: Linux media interface: v0.10
[ 4468.571920] Linux video capture interface: v2.00
root@kjpark-F9SG:/dev# lsmod | grep videodev
videodev 143360 4 uvcvideo,stk11xx,v4l2_common,videobuf2_core
media 24576 2 uvcvideo,videodev
modprobe uvcvideo
[ 4505.015223] usbcore: registered new interface driver uvcvideo
[ 4505.015227] USB Video Class driver (1.1.1)
root@kjpark-F9SG:/dev# lsmod | grep uvcvideo
uvcvideo 77824 0
videobuf2_vmalloc 16384 1 uvcvideo
videobuf2_core 49152 1 uvcvideo
videodev 143360 4 uvcvideo,stk11xx,v4l2_common,videobuf2_core
media 24576 2 uvcvideo,videodev
insmod stk11xx.ko
[ 4527.947957] stk11xx: Syntek USB2.0 webcam driver startup
[ 4527.947961] stk11xx: Copyright(c) 2006-2009 Nicolas VIVIEN
[ 4527.947995] stk11xx: Syntek USB2.0 - STK-1135 based webcam found.
[ 4527.947997] stk11xx: Syntek AVStream USB2.0 1.3M WebCam - Product ID 0x6A33.
[ 4527.947999] stk11xx: Release: 0005
[ 4527.948001] stk11xx: Number of interfaces : 1
[ 4527.949481] stk11xx: Initialize USB2.0 Syntek Camera
[ 4528.545121] stk11xx: Syntek USB2.0 Camera is ready
[ 4528.545966] stk11xx: Syntek USB2.0 Camera is now controlling video device /dev/video0
[ 4528.546551] usbcore: registered new interface driver usb_stk11xx_driver
[ 4528.546556] stk11xx: v2.2.0 : Syntek USB Video Camera
[ 4529.358087] stk11xx: Check device return error (0x0201 = 0C) !
[ 4529.360443] stk11xx: Check device return error (0x0201 = 0C) !
root@kjpark-F9SG:/dev# lsmod | grep stk11xx
stk11xx 143360 0
videodev 143360 4 uvcvideo,stk11xx,v4l2_common,videobuf2_core
Finally, a video device will be created as like follow.
root@kjpark-F9SG:/dev# ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 Mar 23 12:37 /dev/video0
root@kjpark-F9SG:/dev#
How to load the kernel module and driver after boot-up
1. Copy the stk11xx.ko to /lib/modules/`uname -r`/kernel/drivers folder
mkdir /lib/modules/`uname -r`/kernel/drivers/syntek
cp stk11xx.ko /lib/modules/`uname -r`/kernel/drivers/syntek
sync
depmod /lib/modules/`uname -r`/kernel/drivers/syntek/stk11xx.ko
2. Add the required modules to /etc/modules file
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
lp
videodev
uvcvideo
stk11xx
3. After reboot the Ubuntu, check lsmod for stk11xx
References :
https://doc.ubuntu-fr.org/syntek
http://lxr.free-electrons.com/source/include/media/v4l2-dev.h#L37http://dmaiorino.com/?p=12