一、硬件
二、安装软件
安装需要用到的软件
apt-get install -y v4l-utils
apt-get install -y fswebcam
三、内核配置
将sun4i-csi和ov2640编译成模块,后面手动加载驱动。
加载驱动:ov2640.ko
cd /lib/modules/5.4.99
root@wangpi:/lib/modules/5.4.99# insmod ov2640.ko
[ 71.274852] ov2640 0-0030: ov2640 Product ID 26:42 Manufacturer ID 7f:a2
[ 71.282151] i2c i2c-0: OV2640 Probed
i2cdetect -y 0
加载驱动:sun4i-csi.ko
root@wangpi:/lib/modules/5.4.99# insmod sun4i-csi.ko
[ 75.360037] suniv-f1c100s-pinctrl 1c20800.pinctrl: pin PE6 already requested by 1c21000.pwm; cannot claim for 1cb0000.csi
[ 75.372102] suniv-f1c100s-pinctrl 1c20800.pinctrl: pin-134 (1cb0000.csi) status -22
[ 75.380549] suniv-f1c100s-pinctrl 1c20800.pinctrl: could not request pin 134 (PE6) from group PE6 on device 1c20800.pinctrl
[ 75.392772] sun4i-csi 1cb0000.csi: Error applying setting, reverse things back
[ 75.400756] sun4i-csi: probe of 1cb0000.csi failed with error -22
出现错误提示,需要修改设备树了,PE6引脚被占用。设备树去掉背光驱动部分内容。硬件去掉R44,改用R46默认上拉吧。
使用修改后的设备树,重新加载驱动:sun4i-csi.ko
root@wangpi:/lib/modules/5.4.99# insmod sun4i-csi.ko
[ 75.954502] sun4i csi probe
[ 75.958001] sun4i-csi 1cb0000.csi: Packed (RAW) format enabled.
[ 75.974409] sun4i-csi 1cb0000.csi: Device registered as video0
在/dev/目录下出现media0和video0。
四、查看信息
media-ctl -p -d /dev/media0
v4l2-ctl --list-devices
v4l2-ctl --list-formats-ext --device /dev/video0
root@wangpi:/lib/modules/5.4.99# media-ctl -p -d /dev/media0
Media controller API version 5.4.99
Media device information
------------------------
driver sun4i-csi
model Allwinner Video Capture Device
serial
bus info
hw revision 0x0
driver version 5.4.99
Device topology
- entity 1: ov2640 0-0030 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev0
pad0: Source
[fmt:UYVY8_2X8/800x600 field:none colorspace:srgb
crop.bounds:(0,0)/1600x1200
crop:(0,0)/1600x1200]
-> "sun4i-csi-0":0 [ENABLED,IMMUTABLE]
- entity 3: sun4i-csi-0 (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Sink
[fmt:YUYV8_2X8/640x480 field:none colorspace:raw]
<- "ov2640 0-0030":0 [ENABLED,IMMUTABLE]
pad1: Source
[fmt:YUYV8_2X8/640x480 field:none colorspace:raw]
-> "sun4i_csi":0 [ENABLED,IMMUTABLE]
- entity 6: sun4i_csi (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "sun4i-csi-0":1 [ENABLED,IMMUTABLE]
root@wangpi:/lib/modules/5.4.99# v4l2-ctl --list-devices
sun4i-csi (platform:1cb0000.csi):
/dev/video0
Allwinner Video Capture Device (platform:sun4i-csi):
/dev/media0
root@wangpi:/lib/modules/5.4.99# v4l2-ctl --list-formats-ext --device /dev/video0
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YM12' (Planar YUV 4:2:0 (N-C))
[1]: 'YUYV' (YUYV 4:2:2)
[2]: 'UYVY' (UYVY 4:2:2)
五、采集图像
设置图像格式:
- media-ctl --set-v4l2 ‘“ov2640 0-0030”:0[fmt:YUYV8_2X8/640x480]’
拍照测试:
- fswebcam -d /dev/video0 --no-banner -r 640x480 -S 10 2.jpg
如果不去R44电阻,被出现闪屏。
六、问题
拍的照片很糊,是R44电阻的影响吗?等去掉再试试。
七、参考
http://wiki.lcmaker.com/index.php?title=LC-PI-200S
https://blog.csdn.net/mjmmm/article/details/136311441