[国嵌攻略][170][摄像头驱动开发]
摄像头系统架构
V4L2 video for linux,专门为Linux系统定制的操作摄像头的规范。给应用程序提供访问摄像头统一的接口。相应的摄像头驱动也需要遵循V4L2规范。这样应用程序可以不根据硬件的不同而改变,提高应用程序的可移植性。
使能和测试摄像头驱动
make menuconfig ARCH=arm
device drivers-><*>multimedia support-><*>video for linux and [*]enable video for linux api 1
device drivers-><*>multimedia support->[*]video capture adapters->[*]v4l usb devices-><*>gspca based webcams-><*>zc3xx usb camera driver
make uImage ARCH=arm CROSS_COMPILE=arm-linux-
编译测试程序
修改dev_name = "/dev/video%d"为对应的设备文件名
arm-linux-gcc camera.c -o camera
还需要配置uboot
setenv bootargs noinitrd console=ttySAC0,115200 init=/linuxrc root=/dev/nfs rw nfsroot=192.168.1.101:.../rootfs,proto=tcp,nfsvers=3 ip=192.168.1.230:192.168.1.101:192.168.1.1:255.255.255.0::eth0:off saveenv
vim board/samsung/mini2440/smdk2410.c
/* configure MPLL */
writel((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV,
&clk_power->mpllcon);
/* some delay between MPLL and UPLL */
pll_delay(4000);
pll_delay(4000);
/* configure UPLL */
writel((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV,
&clk_power->upllcon);
/* some delay between MPLL and UPLL */
pll_delay(8000);
/* set up the I/O ports */
在MPLL和UPLL之间加了一个pll_delay(4000);
还需要配置kernel
[*]Networking support->Networking options->[*]IP: kernel level autoconfiguration and [*]IP: DHCP support and [*]IP:BOOTP support and [*]IP: RARP support
运行程序如果遇到EHCI USB主控器问题,可以修改相关的USB控制器配置。device drivers->[*]usb support-><*>EHCI HCD (usb 2.0) support or <*>OHCI HCD support