liunx环境,摄像头无法识别,解决方案
今天无语了,linux14.04 系统下,使用罗技 c270 摄像头。发现插上没有反应,系统版本:
lenovo-myc@lenovomyc-Lenovo-Product:~/Downloads$ uname -a Linux lenovomyc-Lenovo-Product 3.13.0-61-generic #100-Ubuntu SMP Wed Jul 29 11:21:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
找了一上午 UVC 驱动,最后发现是测试摄像头的程序 cheese 刚刚有点问题
--------------------------------------------------- 这是分割线 ----------------------------------------------------
下载了 luvcview, 运行,正常工作
lenovo-myc@lenovomyc-Lenovo-Product:~/Downloads$ sudo apt-get install luvcview Reading package lists... Done Building dependency tree Reading state information... Done luvcview is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. lenovo-myc@lenovomyc-Lenovo-Product:~/Downloads$ luvcview luvcview 0.2.6SDL information:
Video driver: x11
A window manager is available
Device information:
Device path: /dev/video0
Stream settings:
Frame format: MJPG
Frame size: 640x480
Frame rate: 30 fps
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
find DRI
--------------------------------------------------- 以下是上午进行的尝试 ---------------------------------------------------
(1)判断是否为 UVC 设备
http://blog.csdn.net/myarrow/article/details/8465384
判断一个摄像头是否属于 UVC 规范可以使用下面方法:
1. 使用 lsusb 命令或其它硬件信息查看工具找出摄像头的设备号 (Vendor ID) 和产品号(Product ID)。如 Logitech Quickcam for Notebooks Pro 摄像头是 046d:08cb;
2. 查找是否有视频类接口信息
lsusb -d 046d:08cb -v | grep "14 Video"
如果该摄像头兼容 UVC,则会输出类似信息
bFunctionClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
bInterfaceClass 14 Video
若无以上信息,则是 non-UVC 设备。
(2) uvc 官网 http://www.ideasonboard.org/uvc/ 有说明:
Linux 2.6.26 and newer includes the Linux UVC driver natively. You will not need to download the driver sources manually unless you want to test a newer version or help with development.
就是说:linux 2.6.26 以及高版本内核都自带 UVC 驱动的。还以为系统有问题
系统目录下也有 /dev/video0 文件,说明摄像头驱动正常
lsusb 输出当前 usb 设备
罗技 C270 为 046d:0825
lenovo-myc@lenovomyc-Lenovo-Product:/dev$ lsusb Bus 002 Device 012: ID 046d:0825 Logitech, Inc. Webcam C270 Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 17ef:6019 Lenovo Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
(3)ubuntu 下使用 UVC 摄像头 http://blog.csdn.net/xingyu19871124/article/details/5764954
分别下载了
1、v41-dvb
网址:http://linuxtv.org/hg/v4l-dvb/ make 的时候出错,版本不匹配。是针对 linux 3.3.0 版本编译的, 当前版本为 3.13.0 报错:
UVC File not found: /lib/modules/3.3.0-61-generic/build/.config
又根据:
http://blog.sina.com.cn/s/blog_3dc687f30100kwf5.html
尝试 make config 依旧不行,放弃
重新 clone 了一遍源码
lenovo-myc@lenovomyc-Lenovo-Product:/dev$ git clone git://linuxtv.org/media_build.git
make (编译内核 。。。)
lenovo-myc@lenovomyc-Lenovo-Product:~/Downloads/media_build$ make make -C /home/lenovo-myc/Downloads/media_build/v4l make[1]: Entering directory `/home/lenovo-myc/Downloads/media_build/v4l' Updating/Creating .config make[2]: Entering directory `/home/lenovo-myc/Downloads/media_build/linux' Applying patches for kernel 3.13.0-61-generic patch -s -f -N -p1 -i ../backports/api_version.patch patch -s -f -N -p1 -i ../backports/pr_fmt.patch patch -s -f -N -p1 -i ../backports/debug.patch patch -s -f -N -p1 -i ../backports/drx39xxj.patch patch -s -f -N -p1 -i ../backports/v4.1_pat_enabled.patch patch -s -f -N -p1 -i ../backports/v4.0_dma_buf_export.patch patch -s -f -N -p1 -i ../backports/v4.0_drop_trace.patch patch -s -f -N -p1 -i ../backports/v3.16_netdev.patch patch -s -f -N -p1 -i ../backports/v3.16_wait_on_bit.patch patch -s -f -N -p1 -i ../backports/v3.16_void_gpiochip_remove.patch Patched drivers/media/dvb-core/dvbdev.c Patched drivers/media/v4l2-core/v4l2-dev.c Patched drivers/media/rc/rc-main.c make[2]: Leaving directory `/home/lenovo-myc/Downloads/media_build/linux' Preparing to compile for kernel version 3.13.0WARNING: You do not have the full kernel sources installed.
This does not prevent you from building the v4l-dvb tree if you have the
kernel headers, but the full kernel source may be required in order to use
make menuconfig / xconfig / qconfig.If you are experiencing problems building the v4l-dvb tree, please try
building against a vanilla kernel before reporting a bug.Vanilla kernels are available at http://kernel.org.
On most distros, this will compile a newly downloaded kernel:cp /boot/config-
uname -r
<your kernel dir>/.config
cd <your kernel dir>
make all modules_install installPlease see your distro's web site for instructions to build a new kernel.
WARNING: This is the V4L/DVB backport tree, with experimental drivers
backported to run on legacy kernels from the development tree at:
http://git.linuxtv.org/media-tree.git.
It is generally safe to use it for testing a new driver or
feature, but its usage on production environments is risky.
Don't use it in production. You've been warned.
V4L2_FLASH_LED_CLASS: Requires at least kernel 4.2.0
RC_ST: Requires at least kernel 3.15.0
VIDEO_XILINX: Requires at least kernel 3.17.0
I2C_SI4713: Requires at least kernel 3.17.0
VIDEO_ADV7604: Requires at least kernel 3.17.0
VIDEO_MT9P031: Requires at least kernel 3.17.0
VIDEO_MT9V032: Requires at least kernel 3.19.0
VIDEO_SMIAPP: Requires at least kernel 4.0.0
SOC_CAMERA_OV2640: Requires at least kernel 3.17.0
Created default (all yes) .config file
./scripts/make_myconfig.pl
make[1]: Leaving directory/home/lenovo-myc/Downloads/media_build/v4l<span style="color: rgba(128, 0, 0, 1)">' </span>make[<span style="color: rgba(128, 0, 128, 1)">1</span>]: Entering directory
/home/lenovo-myc/Downloads/media_build/v4l'
perl scripts/make_config_compat.pl /lib/modules/3.13.0-61-generic/build ./.myconfig ./config-compat.h
creating symbolic links...
make -C firmware prep
make[2]: Entering directory/home/lenovo-myc/Downloads/media_build/v4l/firmware<span style="color: rgba(128, 0, 0, 1)">' </span>make[<span style="color: rgba(128, 0, 128, 1)">2</span>]: Leaving directory
/home/lenovo-myc/Downloads/media_build/v4l/firmware'
make -C firmware
make[2]: Entering directory/home/lenovo-myc/Downloads/media_build/v4l/firmware<span style="color: rgba(128, 0, 0, 1)">' </span>Generating vicam/<span style="color: rgba(0, 0, 0, 1)">firmware.fw Generating ttusb</span>-budget/<span style="color: rgba(0, 0, 0, 1)">dspbootcode.bin Generating cpia2</span>/<span style="color: rgba(0, 0, 0, 1)">stv0672_vp4.bin Generating av7110</span>/<span style="color: rgba(0, 0, 0, 1)">bootcode.bin make[</span><span style="color: rgba(128, 0, 128, 1)">2</span>]: Leaving directory
/home/lenovo-myc/Downloads/media_build/v4l/firmware'
Kernel build directory is /lib/modules/3.13.0-61-generic/build
make -C ../linux apply_patches
make[2]: Entering directory/home/lenovo-myc/Downloads/media_build/linux<span style="color: rgba(128, 0, 0, 1)">' </span>Patches <span style="color: rgba(0, 0, 255, 1)">for</span> <span style="color: rgba(128, 0, 128, 1)">3.13</span>.<span style="color: rgba(128, 0, 128, 1)">0</span>-<span style="color: rgba(128, 0, 128, 1)">61</span>-<span style="color: rgba(0, 0, 0, 1)">generic already applied. make[</span><span style="color: rgba(128, 0, 128, 1)">2</span>]: Leaving directory
/home/lenovo-myc/Downloads/media_build/linux'
make -C /lib/modules/3.13.0-61-generic/build SUBDIRS=/home/lenovo-myc/Downloads/media_build/v4l modules
make[2]: Entering directory/usr/src/linux-headers-<span style="color: rgba(128, 0, 128, 1)">3.13</span>.<span style="color: rgba(128, 0, 128, 1)">0</span>-<span style="color: rgba(128, 0, 128, 1)">61</span>-generic<span style="color: rgba(128, 0, 0, 1)">' </span> CC [M] /home/lenovo-myc/Downloads/media_build/v4l/<span style="color: rgba(0, 0, 0, 1)">bt87x.o LD [M] </span>/home/lenovo-myc/Downloads/media_build/v4l/snd-<span style="color: rgba(0, 0, 0, 1)">bt87x.o Building modules, stage </span><span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">. MODPOST </span><span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(0, 0, 0, 1)"> modules CC </span>/home/lenovo-myc/Downloads/media_build/v4l/snd-<span style="color: rgba(0, 0, 0, 1)">bt87x.mod.o LD [M] </span>/home/lenovo-myc/Downloads/media_build/v4l/snd-<span style="color: rgba(0, 0, 0, 1)">bt87x.ko make[</span><span style="color: rgba(128, 0, 128, 1)">2</span>]: Leaving directory
/usr/src/linux-headers-3.13.0-61-generic'
./scripts/rmmod.pl check
Can't locate Proc/ProcessTable.pm in @INC (you may need to install the Proc::ProcessTable module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at ./scripts/rmmod.pl line 4.
BEGIN failed--compilation aborted at ./scripts/rmmod.pl line 4.
make[1]: *** [default] Error 2
make[1]: Leaving directory `/home/lenovo-myc/Downloads/media_build/v4l'
make: *** [all] Error 2
2、gspcav1-20071224.tar.gz
网址:http://mxhaard.free.fr/download.html
make 依旧出错
后来下载了 luvciew。发现摄像头可以运行! 好吧,到此结束
---------------------------------------------------other---------------------------------------------------
1、查看摄像头 ID:
[root@151 dev]# lsusb
Bus 002 Device 013: ID 0ac8:3313 Z-Star Microelectronics Corp.
0xc8:3313 在UVC中支持了。
2、插入摄像头后,就可以在 /dev/ 下查看是否有 video 设备文件:
[root@151 dev]# ls | grep video
video
video0
其中,video 是 video0 的连接。如果没有再现,可能UVC没有配置到内核中,重新配置就可以了
(大致在 Device DriversàMultimedia devicesàVideo capture adaptersàV4L USB devices 下面)。如果内核配置了,
还是不出现,可以使用 modprobe uvcvideo 来加载该模块。
3、先看看摄像头的相关信息:
lshal | grep Cam
出现:
info.product = 'Vega USB 2.0 Camera.' (string)
usb_device.product = 'Vega USB 2.0 Camera.' (string)
usb.interface.description = 'Vega USB 2.0 Camera.' (string)
info.product = 'Vega USB 2.0 Camera.' (string)
input.product = 'Vega USB 2.0 Camera.' (string)
info.product = 'Vega USB 2.0 Camera.' (string)
对USB有研究的,就很熟悉这些字段。
再看一下系统能不能识别出摄像头:
[root@151 log]# dmesg | grep Cam
uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)
input: Vega USB 2.0 Camera. as /class/input/input6
usb 2-7: Product: Vega USB 2.0 Camera.
uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)
input: Vega USB 2.0 Camera. as /class/input/input7
usb 2-7: Product: Vega USB 2.0 Camera.
uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)
input: Vega USB 2.0 Camera. as /class/input/input8
usb 2-7: Product: Vega USB 2.0 Camera.
[root@151 ~]# dmesg | grep video
pci 0000:05:00.0: Boot video device
Linux video capture interface: v2.00
usbcore: registered new interface driver uvcvideo
uvcvideo 2-7:1.0: usb_probe_interface
uvcvideo 2-7:1.0: usb_probe_interface - got id
uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)
uvcvideo 2-7:1.0: usb_probe_interface
uvcvideo 2-7:1.0: usb_probe_interface - got id
uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)
uvcvideo 2-7:1.0: usb_probe_interface
uvcvideo 2-7:1.0: usb_probe_interface - got id
uvcvideo: Found UVC 1.00 device Vega USB 2.0 Camera. (0ac8:3313)