ARM基于Linux系统下的视频监控(初步)

在内核汇中添加摄像头驱动

一、移植gspcav1-20071224

gspcav1-20071224 下载地址

FS2410开发板上移植的是Linux-2.6.22.6内核,USB及CS8900A均能工作,由于linux-2.6.22.6/drivers/usb 目录下没有 media 目录,故移植步骤如下:

步骤一、在 linux-2.6.22.6/drivers/usb 目录下新建 media 目录,将gspcav1-20071224.tar.gz copy

到 media 下并解压。

步骤二、为了使media 编译进内核,,需修改linux-2.6.22.6/drivers/usb 目录下的Kconfig、Makefile 文件。[linux@ usb]$ pwd/work/kernel/linux-2.6.22.6/drivers/usb

[linux@ usb]$ vi Kconfig添加source “drivers/usb/media/Kconfig”

[linux@ usb]$ vi Makefile添加obj-$(CONFIG_USB_SPCA5XX) += media/

步骤三、为加载gspcav1-20071224驱动编译选项,在 media 下新建 Kconfig、Makefile 文件。

[linux@ media]$ pwd/work/kernel/linux-2.6.22.6/drivers/usb/media[linux@ media]$ vim Kconfig

## USB Multimedia device configuration#comment “USB Multimedia devices” depends on USB

config USB_SPCA5XX tristate “USB SPCA5XX Sunplus/Vimicro/Sonix jpeg Cameras” depends on USB && VIDEO_DEV —help— Say Y or M here if you want to use one of these webcams:

The built-in microphone is enabled by selecting USB Audio support.

This driver uses the Video For Linux API. You must say Y or M to “Video For Linux” (under Character Devices) to use this driver. Information on this API and pointers to “v4l” programs may be found at <file:Documentation/video4linux/API.html>.

To compile this driver as a module, choose M here: the module will be called spca5xx.

[linux@ media]$ vim Makefile## Makefile for USB Media drivers#

obj-$(CONFIG_USB_SPCA5XX) += gspcav1-20071224/

步骤四、修改 gspcav1-20071224 的 Makefile

[linux@ gspcav1-20071224]$ pwd/work/kernel/linux-2.6.22.6/drivers/usb/media/gspcav1-20071224[linux@ gspcav1-20071224]$ vi Makefile

gspca-objs := gspca_core.o decoder/gspcadecoder.oobj-$(CONFIG_USB_SPCA5XX) += gspca.o

clean: rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c rm -rf .tmp_versions

步骤五、编译内核(1)Device Drivers —> Multimedia devices —> [*]Enable Video For Linux API 1 (DEPRECATED) <*>Video For Linux [*]video capture adapters —> [*]V4L USB devices —>(2)Device Drivers —> USB support —> <*>Support for Host-side USB — USB Host Controller Drivers <*>OHCI HCD support — USB Multimedia devices <M>USB SPCA5XX Sunplus/Vimicro/Sonix jpeg Cameras

此时,可能会提示 drivers/usb/media/gspcav1-20071224/gspca_core.c 的一些轻微错误,稍作修改即

可://static const char gspca_version[] = GSPCA_VERSION;static const char gspca_version[] = “00.60.00”;编译内核及内核模块 make uImage modules 把uImage拷到交叉编译的内核下载文件架中生成的内核模块/drivers/usb/media/gspcav1-20071224/gspca.ko文件拷到交叉编译的文件系统的任意文件夹如/tmp然后在板上安装模块 insmod gspca.ko

插上usb摄像头出现如下信息:# usb 1-1: new full speed USB device using s3c2410-ohci and address 3usb 1-1: configuration #1 chosen from 1 choicedrivers/usb/media/gspcav1-20071224/gspca_core.c: USB GSPCA camera found.(ZC3XX)drivers/usb/media/gspcav1-20071224/gspca_core.c: [spca5xx_probe:4276] Camera type JPEGdrivers/usb/media/gspcav1-20071224/Vimicro/zc3xx.h: [zc3xx_config:638] Find Sensor PB0330.

Chip revision 0drivers/usb/media/gspcav1-20071224/gspca_core.c: [spca5xx_getcapability:1250] maxw 640 maxh

480 minw 160 minh 120说明移植的驱动已经能识别设备,如果udev安装好的话,设备名所在路径 /dev/video0。

到此内核加载驱动完成,但这样需要每次启动都手动安装模块。(把驱动编译进内核会有问题,问题未解决)

安装好驱动后就可以使用测试程序mouse_capture进行抓图了把mouse_capture-daily3文件夹的mouse_capture拷到网络文件系统下 /opt/filesystem/tmp然后在板上运行./mouse_capture就可以自动抓拍到一张图片1.jpg存放在/tmp目录下这时可以通过从虚拟机的Ubuntu界面进入网络文件系统的tmp目录下查看该图片。

移植servfox

修改Makefile文件为:

CC=arm-linux-gnu-gcc

SERVFLAGS= -O2 -DLINUX $(WARNINGS) -I/home/yuaf/linux-2.6.22.6/include(I地址填你的内核的

include文件夹位置)

然后make一下,在当前文件夹下就可以看到生成的可执行文件 servfox,把此可执行文件拷贝到网络文件

系统下 /opt/filesystem/bin

在开发板中运行 servfox -d /dev/video0 -s 640×480 -w 7070(7070为服务器端口号),就可以看到如下

的提示信息:

# ./servfox -d /dev/video0 -s 640×480 -w 7070servfox version: 1.1.2 date: 07:10:2005 (C) mxhaard@magic.frdrivers/usb/media/gspcav1-20071224/gspca_core.c: [gspca_set_isoc_ep:946] ISO EndPoint found

0x81 AlternateSet 7drivers/usb/media/gspcav1-20071224/gspca_core.c: [spca5xx_do_ioctl:2125] Bridge ZC301-2drivers/usb/media/gspcav1-20071224/gspca_core.c: [gspca_set_isoc_ep:946] ISO EndPoint found

0x81 AlternateSet 7Waiting …. for connection. CTrl_c to stop !!!!说明servfox视频服务器已成功运行起来了。

我的眼泪流了下来,浇灌了下面柔软的小草,

ARM基于Linux系统下的视频监控(初步)

相关文章:

你感兴趣的文章:

标签云: