移植spca5xx-v4l1goodbye到立宇泰ARMSYS244O开发板

发 布 时 间 : 2008-11-19 来 源 : 未知 作 者 : meteor1516 浏 览 :
前面我讲解了如何移植spca5xxle到立宇泰ARMSYS244O开发板。但是spca5xxle只能输出JPG格式的图像数据,如果我们想要RGB格式的数据就必须自己解码,如果移植的是完整的spca5xx驱动就不会有这些问题。所以今天我将spca5xx-v4l1goodbye到立宇泰ARMSYS244O开发板上。

我的开发板是立宇泰ARMSYS2440,内核是2.4.20_elfin-d1.5。
1、首先下源码包spca5xx-v4l1goodbye.tar.gz,然后解压
#tar -xzvf spca5xx-v4l1goodbye.tar.gz
解压后得到一个spca5xx-v4l1goodbye目录,里边是spca5xx-v4l1goodbye的源代码。

2、修改Makefile
#cd spca5xx-v4l1goodbye
#gedit Makefile&

ifneq ($(shell uname -r | cut -d. -f1,2), 2.4)

ifneq ($(KERNELRELEASE),) # We were called by kbuild
CFLAGS = $(DEFINES)
obj-m = spca5xx.o
spca5xx-objs := drivers/usb/spca5xx.o drivers/usb/spcadecoder.o

else # We were called from command line

KERNEL_VERSION = `uname -r`
KERNELDIR := /lib/modules/$(KERNEL_VERSION)/build
PWD := $(shell pwd)
MODULE_INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/usb/media/

# Targets, don't change!
default:
@echo ' Building SPCA5XX driver for 2.5/2.6 kernel.'
@echo ' Remember: you must have read/write access to your kernel source tree.'
$(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) CC=$(CC) modules

install:
mkdir -p $(MODULE_INSTALLDIR)
rm -f $(MODULE_INSTALLDIR)spca50x.ko
rm -f $(MODULE_INSTALLDIR)et61x.ko
install -c -m 0644 spca5xx.ko $(MODULE_INSTALLDIR)
/sbin/depmod -ae

uninstall:
rm -f $(MODULE_INSTALLDIR)/spca5xx.ko
/sbin/depmod -aq

endif

else # kernel version test
以及
endif # End kernel version test
删除,应为这些都是针对2.6内核的,我们不需要。

KERNEL_VERSION = `uname -r`
替换为自己的内核版本号,我的是
KERNEL_VERSION = 2.4.20_elfin-d1.5

KINCLUDE = /lib/modules/$(KERNEL_VERSION)/build/include
替换为自己的内核的代码路径
KINCLUDE = /root/kenerl2440_64m30/include

CC = gcc
LD = ld
替换为
CC = /usr/local/arm/2.95.3/bin/arm-linux-gcc
LD = /usr/local/arm/2.95.3/bin/arm-linux-ld

3、修改scpca5xx目录下spca5xx.c
找到定义spca5xx_driver的地方,将原来的定义

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,22)
static struct usb_driver spca5xx_driver = {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
.owner = THIS_MODULE,
#endif
.name = "spca5xx",
.id_table = device_table,
.probe = spca5xx_probe,
.disconnect = spca5xx_disconnect
};
#else
static struct usb_driver spca5xx_driver = {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,20)
THIS_MODULE,
#endif
"spca5xx",
spca5xx_probe,
spca5xx_disconnect,
{NULL, NULL}
};
#endif

替换为下边的内容:

static struct usb_driver spca5xx_driver = {
name: "spca5xx",
id_table: device_table,
probe: spca5xx_probe,
disconnect: spca5xx_disconnect
};
找到spca5xx_probe函数定义的地方,将原来的

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
static int
spca5xx_probe(struct usb_interface *intf, const struct usb_device_id *id)
#else
static void *spca5xx_probe(struct usb_device *dev, unsigned int ifnum,
const struct usb_device_id *id)
#endif

替换为:

static void *
spca5xx_probe (struct usb_device *dev, unsigned int ifnum,
const struct usb_device_id *id)
如果不修改这两个地方,编译不会有问题,但是驱动不能工作。

4、编译
#make
在spca5xx-v4l1goodbye目录下生成spca5xx.o文件,这就是我们需要的驱动。将这个文件拷到开发板的文件系统里。

5、将驱动加载到内核
#insmod spca5xx.o
Using spca5xx.o
drivers/usb/spca5xx.c: Unable to initialise /proc/video/spca50x//提示无法初始化,先不管
usb.c: registered new driver spca5xx
drivers/usb/spca5xx.c: spca5xx driver 00.60.00.1 registered

插上你的zc301摄像头,就可以看到如下的信息
[root@lyt /]# hub.c: new USB device usb-ohci-1, assigned address 2
Manufacturer: Vimicro Corp.
Product: PC Camera
drivers/usb/spca5xx.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x303b
drivers/usb/spca5xx.c: [spca5xx_probe:5488] Camera type JPEG
drivers/usb/zc3xx.h: [zc3xx_config:527] Find Sensor PB0330
drivers/usb/spca5xx.c: [spca5xx_getcapability:1767] maxw 640 maxh 480 minw 176 minh 144
同时在/dev下创建了v4l/video0设备文件。
恭喜你的摄像头现在可以使用了。



上一篇:移植spcaxx-le到立宇泰ARMSYS2440开发板 下一篇:Windows CE矩阵键盘开发