正文

移植spcaxx-le到立宇泰ARMSYS244O开发板2009-04-09 10:32:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/liyutai/42050.html

分享到:

我的开发板是立宇泰ARMSYS2440,内核是2.4.20_elfin-d1.5。
1、首先下载补丁usb-2.4.31LE06.patch.tar,然后解压到内核目录的driver/usb目录下
#cp usb-2.4.31LE06.patch.tar driver/usb
#cd driver/usb
#tar -xzvf usb-2.4.31LE06.patch.tar
解压后得到一个usb-2.4.31patch的补丁文件

2、给内核打补丁
#patch -p1 < usb-2.4.31patch
打完补丁之后在driver/usb目录下生成了一个spcaxx的目录,里面有我们需要的驱动源码文件。在driver/usb目录下生成了一个Makefile.rej的文件,将该文件中行首有加号的部分添加到Makefile文件中
对应的部分。

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

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,22)
static struct usb_driver spca5xx_driver = {
.owner = THIS_MODULE,
.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、配置内核
选中multimedia devices->video for linux
选中usb support->usb multimedia devices->usb spca5xx sunplus vimico sonix cameras
注意:这里的选中都是指以M的方式选中,video for linux也可以直接编译进内核,但是这样你必须更换你的内核了,而usb spca5xx sunplus vimico sonix cameras必须以M的方式选中,不能直接编译进内核,否则会出错。

5、编译
#make clean
#make dep
#make zImage
#make modules
这样会在driver/usb/soca5xx目录下生成spca5xx.o、spca_core.o和spcadecoder.o三个驱动文件,如果video for linux是以M的方式选中的话在/drivers/media/vido目录下生成videodev.o驱动文件。
将这些4个.o文件拷到开发板文件系统里

6、将编译好的驱动加载到内核
#insmod videodev.o //如果是以M的方式选中video for linux,需要做这部,否则不需要
#insmod spca5xx.o
#insmod spca_core.o
#insmod spcadecoder.o //会有个警告,可以不管它

插上你的zc301摄像头,就可以看到如下的信息
[root@lyt /camdrv]# usb.c: USB disconnect on device usb-ohci-1 address 2
hub.c: new USB device usb-ohci-1, assigned address 3
Manufacturer: Vimicro Corp.
Product: PC Camera
spca_core.c: probe spca5xx camera
spca_core.c: Detect camera vendor=2760, product=12347
spca_core.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x303b
同时在/dev下创建了v4l/video0设备文件。
恭喜你的摄像头现在可以使用了。

更多文章请点击查看:http://www.hzlitai.com.cn/article/ARM9-article/1-16.html

阅读(1726) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册