linux version 2.4.18-rmk7-pxa1,基于arm2410 ,kernel2.4.18,zc301芯片=>spca5xx完整版驱动

前面讲解了如何移植spca5xx le版的驱动到立宇泰ARMSYS241O开发板。但是spca5xxle只能输出JPG格式的图像数据,如果我们想要 RGB格式的数据就必须自己解码,如果移植的是完整的spca5xx驱动就不会有这些问题。所以今天我将spca5xx-v4l1goodbye到立宇泰 ARMSYS241O开发板上。

我的开发板是立宇泰ARMSYS2410,内核是2.4.18-rmk7-pxa1。

1、首先下源码包spca5xx-v4l1goodbye.tar.gz (如果需要驱动文件请联系我guohui.great@gmail.com),然后解压

#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.18-rmk7-pxa1

KINCLUDE = /lib/modules/$(KERNEL_VERSION)/build/include

替换为自己的内核的代码路径

KINCLUDE = /root/software/kernel/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)

如果不修改这两个地方,编译不会有问题,但是驱动不能工作。

#CFLAGS += -mpreferred-stack-boundary=2 这个注释掉,否则编译通不过

4、编译

#make

///

可 能出现的问题:

================================================

1.缺少 linux/autoconfig.h,或者linux/version.h,

解决方法:1.选择正确的内核,2.自己手动添加。

================================================

2.[root@localhost spca5xx-20060402]# make

Compiling drivers/usb/spca5xx.c

In file included from /lib/modules/2.4.20-8/build/include/linux/vmalloc.h:8,

from drivers/usb/spca5xx.c:46:

/lib/modules/2.4.20-8/build/include/linux/highmem.h: In function `bh_kmap':

/lib/modules/2.4.20-8/build/include/linux/highmem.h:20: warning: pointer of

type `void *' used in arithmetic

drivers/usb/spca5xx.c: In function `spca5xx_mmap':

drivers/usb/spca5xx.c:5131: warning: passing arg 1 of

`remap_page_range_R2baf18f2' makes pointer from integer without a cast

drivers/usb/spca5xx.c:5131: incompatible type for argument 4 of

`remap_page_range_R2baf18f2'

drivers/usb/spca5xx.c:5131: too few arguments to function

`remap_page_range_R2baf18f2'

drivers/usb/spca5xx.c: At top level:

..........

make: *** [drivers/usb/spca5xx.o] Error 1

解 决办法:

打开源码 spca5xx.c中的spca5xx_mmap,可以发现在这个函数的调用上RH9和RH9以上的版本调用的都不是同一条函数,在 remap_page_range()函数的第一个参数对于RH9就没有做定义,为定义情况下在RH9调用remap_page_range()就缺少了 第一个参数的描述,一个小bug在这里,只要在出错的remap_page_range参数添加第一个参数,设为0,编译就通过了,还有几个 warming可以忽略。

===================================================================

3.#CFLAGS += -mpreferred-stack-boundary=2 这个注释掉,否则编译通不过

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

===================================================================

5、 将驱动加载到内核

#/sbin/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设备文件。

恭喜你的摄像头现在可以使用了。

(秩名)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值