在内核汇中添加摄像头驱动
一、移植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.o
obj-$(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 3
usb 1-1: configuration #1 chosen from 1 choice
drivers/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 JPEG
drivers/usb/media/gspcav1-20071224/Vimicro/zc3xx.h: [zc3xx_config:638] Find Sensor PB0330.
Chip revision 0
drivers/usb/media/gspcav1-20071224/gspca_core.c: [spca5xx_getcapability:1250] maxw 640 maxh
480 minw 160 minh 120
说明移植的驱动已经能识别设备,如果udev安装好的话,设备名所在路径 /dev/video0。
到此内核加载驱动完成,但这样需要每次启动都手动安装模块。(把驱动编译进内核会有问题,问题未解决)