在HHARM2410上驱动中星微摄像头307b

转自:http://blog.csdn.net/sfrysh/article/details/5605228


spca5xx是一个法国老头做的linux下摄像头驱动,对中星微zc301摄像头支持的比较好,于是也想在HHARM2410上玩玩。多方打听,从一个哥们那弄了个中星微摄像头,连在电脑上一测试VID 0ac8,pid 307b,当时心里就凉了半截,这个pid有点高,怕spca支持不了。特意去spca5xx的官网上查了下,都没说对它有支持。无奈,可以zc301的也太不好找了,只能试试了。

    一、 所需源码:

                   (1)驱动:gspcav1-20071224.tar.gz,spca5xx上最新的版本

                   (2)kernel:linux2.6.14

                   (3)servfox-R1_1_3.tar.gz,相当于在板子跑的一个服务器,把采集的视频数据传递给PC 端的spcaview

                   (4)spcaview,运行在PC端的图像显示软件,接收来自severfox上的图像数据并显示

   二、静态编译gspca

         我是把gspca以静态的方式编译到linux内核里的,貌似真正的做产品也都用这种方式,下面是移植过程。

       (1)拷贝gspcav1-20071224.tar.gz到linux-2.6.14.1/drivers/usb/media 目录下解压,得到的文件夹命名为gspca。

       (2)修改gspca/gspca_core.c源程序中的部分代码:

                添加 #define VID_HARDWARE_GSPCA 0xff

                第35行static const char gspca_version[] = GSPCA_VERSION;
                修改为:static const char gspca_version[] = "00.60.00";

        (3)修改gspca/Makefile文件,整个Makefile文件修改后内容如下:

                 gspca-objs := gspca_core.o decoder/gspcadecoder.o

                 obj-$(CONFIG_USB_GSPCA) += gspca.o


                clean:
                          rm -r -f *.o decoder/.gspcadecoder.o.cmd decoder/*.o /
                         .gspca.o.cmd  *.o *.ko *.mod.* .[a-z]* core *.i /
                          *.symvers *.err

        (4)修改linux-2.6.14.1/drivers/usb/media/Makefile文件,添加如下内容

              obj-$(CONFIG_USB_GSPCA)       += gspca/
        (5)修改linux-2.6.14.1/drivers/usb/media/Kconfig文件,在文件最好添加如下内容

              config USB_GSPCA
                        tristate "USB GSPCA  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 gspca

       (6)修改linux-2.6.14.1/drivers/usb/Makefile文件,添加如下内容

                      obj-$(CONFIG_USB_GSPCA)       += media/

      (7)make menuconfig 配置内核,选中一下选项

                   (1)Multimedia devices --->
                          < *>Video For Linux
                   (2) USB support --->
                            <*>Support for Host-side USB
                                 --- USB Host Controller Drivers 
                                  <*>OHCI HCD support
                   (3)--- USB Multimedia devices
                         <*>USB GSPCA Sunplus/Vimicro/Sonix jpeg Cameras
      (8)make zImage 编译内核。
    三、编译severfox

          (1) 解压severfox后修改Makefile为如下内容:

           CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc
           INSTALL=install
           BIN=/usr/local/bin

           SERVFLAGS= -O2 -DLINUX $(WARNINGS)  -           I /home/YXJ/HH2410BSP/kernel/linux-2.6.14.1/include

           SERVLIBS= -lpthread

 

          OBJSERVER= server.o spcav4l.o utils.o tcputils.o


all:     servfox

clean:
        @echo "Cleaning up directory."
        rm -f *.a *.o servfox   core *~ log errlog


servfox: $(OBJSERVER)
        $(CC) $(SERVFLAGS) -o servfox $(OBJSERVER) $(SERVLIBS)

 

server.o:       server.c
                $(CC) $(SERVFLAGS) -c -o $@ $<

spcav4l.o:      spcav4l.c spcav4l.h
                $(CC) $(SERVFLAGS) -c -o $@ $<

utils.o:        utils.c utils.h
                $(CC) $(SERVFLAGS) -c -o $@ $<

tcputils.o:     tcputils.c tcputils.h
                $(CC) $(SERVFLAGS) -c -o $@ $<

 

install_servfox: spcafox
        $(INSTALL) -s -m 755 -g root -o root servfox $(BIN)

 

install: servfox
        $(INSTALL) -s -m 755 -g root -o root servfox $(BIN)

  (3)执行make命令即生成可执行文件severfox,将其拷贝到ramdisk文件系统中。

三、调试效果

        将生成的内核和文件系统下载的HHARM2410上,启动系统,会看到如下提示

        usbcore: registered new driver gspca
        drivers/usb/media/gspca/gspca_core.c: gspca driver 00.60.00 registered

       查上usb摄像头,提示如下

         usb 1-1: new full speed USB device using s3c2410-ohci and address 2
        drivers/usb/media/gspca/gspca_core.c: USB GSPCA camera found.(ZC3XX)

      在severfox所在的目录下执行如下命令:

        ./servfox -d /dev/video0  s 320x240 -w 7070 -g

        终端输出如下提示
           servfox version: 1.1.3 date: 11:12:2005 (C) [email protected]
          wrong spca5xx device
          VIDIOCSWIN failed
          : Invalid argument
          Waiting .... for connection. CTrl_c to stop !!!!

    还是提示有错误信息,估计是307b型号还没被gspca真正支持的怨过,不过此时在pc端运行spcaview软件已经可以看到采集的图像

 

         
  在HHARM2410上驱动中星微摄像头307b_第1张图片


你可能感兴趣的:(在HHARM2410上驱动中星微摄像头307b)