rk3288 isp ov13850
ov13850
Linux下支持驱动主板 Core-3399-JD4
Android 下支持的驱动主板 rk3288 rk3399
http://www.t-firefly.com/doc/product/info/id/285.html 硬件接口原理图
http://dev.t-firefly.com/forum.php?mod=viewthread&tid=12798&highlight=ov13850 应用层
https://blog.csdn.net/huang_165/article/details/86130288
camera0: ov13850@10 {
rockchip,pd-gpio = <&gpio2 14 GPIO_ACTIVE_LOW>; //pd
rockchip,pwr-gpio = <&gpio3 10 GPIO_ACTIVE_HIGH>; // mipi-pwr
rockchip,pwr-2nd-gpio = <&gpio7 12 GPIO_ACTIVE_HIGH>; //cif_pwr
rockchip,rst-gpio = <&gpio3 8 GPIO_ACTIVE_LOW>; //mipi-rest
}
camera0: ov13850@10 {
rockchip,pd-gpio = <&gpio2 12 GPIO_ACTIVE_LOW>;
rockchip,pwr-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;
rockchip,pwr-2nd-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>; //cif_pwr
rockchip,rst-gpio = <&gpio0 8 GPIO_ACTIVE_LOW>; //
}
LCD
VCC_LCD == GPIO7_A3
GPIO_keys power == GPIO0_A5
ov13850
// 1 VCC_SYS ==
// 2 CIF_PWR == DOVDD_1V2
// 3 DVP_PWR == DOVDD_1V8
// 4 I2C3_SDA
// 5 I2C3_SCL
// 6 CIF_RST ===
// 7 PWDN ==
// 9 CIF_CLKOUT
//11 D3P_A
//12 D3N_A
AIO-3288J
// 1 VCC_SYS
// 2 CIF_PWR == ISP_SHUTTEREN/SPI1_CLK/GPIO7_B4_D // 7 12
// 3 MIPI_PWR == FLASH0_RDN/GPIO3_B2_U // 3 10
// 6 MIPI_RST == FLASH0_RDY/GPIO3_B0_U // rst 3 8
// 7. CIF_PDN1 == CIF_D2/HOST_D0/TS_D0/GPIO2_A0_D // J53 MIPI_CSI1 pd 2 0
// 7. CIF_PDN0 == CIF_D10/GPIO2_B6_D // J29 MIPI_CSI0 2 14
// 9. CIF_CLKOUT === MIPI_MCLK0 == CIF_CLKOUT/HOST_W KREQ/TS_FAIL/GPIO2_B3_D // 2 11
rk3399 30P i2c1
PWDN == GPIO2_B4/DVP_PDN0_H // 8*1+4
CIF_POWER == GPIO1_C6/TCPD_VBUS_SOURCE0_d
DVP_PWR == GPIO1_C7/TCPD_VBUS_SOURCE1_d
MIPI_RST == GPIO0_B0/SDMMC0_WRPT/TEST_CLKOUT2_u
arch/arm/boot/dts/rk3288-firefly-aio-lvds.dts
&i2c3 {
status = "okay";
i2c-scl-rising-time-ns = <300>;
i2c-scl-falling-time-ns = <15>;
camera0: ov13850@10 {
status = "okay";
compatible = "omnivision,ov13850-v4l2-i2c-subdev";
reg = < 0x10 >;
device_type = "v4l2-i2c-subdev";
clocks = <&cru SCLK_VIP_OUT>;
clock-names = "clk_cif_out";
pinctrl-names = "rockchip,camera_default", "rockchip,camera_sleep";
pinctrl-0 = <&cam0_default_pins>;
pinctrl-1 = <&cam0_sleep_pins>;
// rockchip,pd-gpio = <&gpio2 12 GPIO_ACTIVE_LOW>;
// rockchip,pwr-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;
// rockchip,pwr-2nd-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>;
// rockchip,rst-gpio = <&gpio0 8 GPIO_ACTIVE_LOW>;
rockchip,pd-gpio = <&gpio2 14 GPIO_ACTIVE_LOW>; //pd
rockchip,pwr-gpio = <&gpio3 10 GPIO_ACTIVE_HIGH>; // mipi-pwr
rockchip,pwr-2nd-gpio = <&gpio7 12 GPIO_ACTIVE_HIGH>; //cif_pwr
rockchip,rst-gpio = <&gpio3 8 GPIO_ACTIVE_LOW>; //mipi-rest
rockchip,camera-module-mclk-name = "clk_cif_out";
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "cmk-cb0695-fv1";
rockchip,camera-module-len-name = "lg9569a2";
rockchip,camera-module-fov-h = "66.0";
rockchip,camera-module-fov-v = "50.1";
rockchip,camera-module-orientation = <0>;
rockchip,camera-module-iq-flip = <0>;
rockchip,camera-module-iq-mirror = <0>;
rockchip,camera-module-flip = <1>;
rockchip,camera-module-mirror = <0>;
rockchip,camera-module-defrect0 = <2112 1568 0 0 2112 1568>;
rockchip,camera-module-defrect1 = <4224 3136 0 0 4224 3136>;
rockchip,camera-module-defrect3 = <3264 2448 0 0 3264 2448>;
rockchip,camera-module-flash-support = <0>;
rockchip,camera-module-mipi-dphy-index = <0>;
};
};
&pinctrl {
cam_pins {
cam0_default_pins: cam0-default-pins {
rockchip,pins =
<4 27 RK_FUNC_GPIO &pcfg_pull_none>,
<2 11 RK_FUNC_3 &pcfg_pull_none>;
};
cam0_sleep_pins: cam0-sleep-pins {
rockchip,pins =
<4 27 RK_FUNC_3 &pcfg_pull_none>,
<2 11 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
};
&cif_isp0 {
rockchip,camera-modules-attached = <&camera0>;
status = "okay";
};
&isp {
status = "okay";
};
&isp_mmu {
status = "okay";
};
&rkisp1_0 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp0_mipi_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&dphy_rx0_out>;
};
};
};
&mipi_dphy_rx0 {
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
mipi_in_ucam0: endpoint@1 {
reg = <1>;
remote-endpoint = <&ucam_out0>;
data-lanes = <1 2>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
dphy_rx0_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&isp0_mipi_in>;
};
};
};
};
&isp0_mmu {
status = "okay";
};
&i2c1 {
status = "okay";
ov13850: ov13850@10 {
compatible = "ovti,ov13850";
status = "okay";
reg = <0x10>;
clocks = <&cru SCLK_CIF_OUT>;
clock-names = "xvclk";
/* conflict with csi-ctl-gpios */
reset-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>;
pwr-gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
pwr_snd-gpios =<&gpio1 22 GPIO_ACTIVE_HIGH>;
pinctrl-names = "rockchip,camera_default";
pinctrl-0 = <&cif_clkout>;
port {
ucam_out0: endpoint {
remote-endpoint = <&mipi_in_ucam0>;
data-lanes = <1 2>;
};
};
};
#if 0
camera0: camera-module@10 {
status = "okay";
compatible = "omnivision,ov13850-v4l2-i2c-subdev";
@@ -101,6 +176,7 @@
rockchip,camera-module-flash-support = <0>;
rockchip,camera-module-mipi-dphy-index = <0>;
};
#endif
};
1.拍照
安装软件包:sudo apt-get install fswebcam
抓取图片:fswebcam –r 640x480test.jpg
其中640x480是图片的分辨率,test.jpg即为抓取后保存的图片。
效果如图:
2.拍摄视频
安装软件包:sudo apt-get install libav-tools
拍摄视频:avconv -f video4linux2 –r 7–s 640x480 –i video.avi
参数7是设置的拍摄时间,640x480是图像分辨率,video.avi即为保存的视频文件。
播放视频:omxplayer –o hdmi video.avi
即通过HDMI输出播放video.avi视频。
以上就是USB摄像头的简单使用,由于USB接口已普遍在电子设备上使用,所以USB摄像头使用起来还是挺方便和实用的。
我打算用v4l-utils工具包中的:v4l2-ctl实现抓图。
V4l2-ctl 工具则是针对/dev/video0,/dev/video1 等 video设备,它在 video 设备上进行 set_fmt,reqbuf(申请buf),qbuf(送buf回队列),dqbuf(从队列取出buf),stream_on,stream_off 等一系列操作。
n为4的倍数(0,1,2,3...)
/dev/videon+0:视频输出 SP主通道
/dev/videon+1:视频输出 MP自身通道
/dev/videon+2:3A统计
/dev/videon+3:3A参数设置
设置 fmt 并抓帧:
板端:
v4l2-ctl -d /dev/video0 --set-selection=target=crop,width=1920,height=1080 --set-fmt-video=width=1280,height=720,pixelformat=NV21
--stream-mmap=3 --stream-to=mp.out --stream-count=1 --stream-poll
参数的说明:
-d,指定操作对象为/dev/video0 设备。
--set-selection=target=crop 设置裁剪功能,width=1920,height=1080 裁剪后的大小1920x1080
--set-fmt-video,指定了宽高及 pxielformat。NV12,即用 FourCC 表示的 pixelformat。FourCC 编码详见下文 FourCC。
--stream-mmap,指定 buffer 的类型为 mmap,即由 kernel 分配的物理连续的或经过iommu 映射的 buffer。
--stream-to,指定帧数据保存的文件路径
--stream-count,指定抓取的帧数, 不包括--stream-skip 丢弃的数量
--stream-poll,该选项指示 v4l2-ctl 采用异步 IO,即在 dqbuf 前先用 select 等等帧数据完成,从而保证 dqbuf 不阻塞。否则 dqbuf 将会阻塞直到有数据帧到来。
那么我们将mp.out推到ubantu上用mplayer打开它。
ubantu端:
W=1280; H=720; mplayer mp.out -loop 0 -demuxer rawvideo -fps 25 -rawvideo w=${W}:h=${H}:size=$((${W}*${H}*3/2)):format=nv21
注意了抓图操作的pixelformat和mplayer播放的format需要一致。
当然了,前提是摄像头驱动和摄像头本身要支持nv12,分辨率也同理。
FourCC:全称 Four Character Codes,它用 4 个字符(即 32bit)来命名图像格式。
以下列出本文中常用到的几个格式。更详细的定义请参阅 kernel 代码之 videodev2.h。
FourCC图:
调试摄像头注意点:
A:上电流程:
摄像头根据采用内/外部DVDD、上电时刻iic是否有效来分出四种上电时序。
1.内部DVDD+iic还无效。
2.内部DVDD+iic有效。
3.外部DVDD+iic还无效。
4.外部DVDD+iic有效。
这是第4种情况
外部DVDD和iic有效图:
B:操作流程
摄像头端的:
1.上电时序、供合适工作时钟(一般24MHZ)
2.复位信号时序
3.ISP设置传输图像数据时序(在这里是DVP时序)
4.摄像头、ISP设置图传的分辨率、速率、格式
做1,2两步通过iic就能把摄像头的ID读出来。
做3,4两步就能从DVP读出图像数据
主板摄像头接口端(ISP)的:主要配置板卡的dts
参考上面的“抓图涉及”一节
附录:
试验的mp.out
成功启动log:
[ 0.879203] ov2659.ov2659_check_camera_id: successfully detected camera ID 0x2656
[ 0.879919] cif_isp10_pltfrm_get_img_src_device: ov2659 attach to cif isp10 img_src_array[0]
[ 0.881313] cif_isp10_v4l2_register_video_device: video device video-1.0 (rkisp10_selfpath) successfully registered
[ 0.882480] video4linux video1: successfully registered video device for cifisp(video1)
[ 0.883705] cif_isp10_v4l2_register_video_device: video device video-1.2 (rkisp10_mainpath) successfully registered
[ 0.884893] cif_isp10_v4l2_register_video_device: video device video-1.3 (rkisp10_dmapath) successfully registered
打开v4l2中的ioctl调用开关:
echo 0x1f > /sys/class/video4linux/video0/dev_debug
echo 0x1f > /sys/class/video4linux/video1/dev_debug
echo 0x1f > /sys/class/video4linux/video2/dev_debug
echo 0x1f > /sys/class/video4linux/video3/dev_debug
ov2659支持:
v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Index : 1
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Index : 2
Type : Video Capture
Pixel Format: 'UYVY'
Name : UYVY 4:2:2
Index : 3
Type : Video Capture
Pixel Format: '422P'
Name : Planar YVU 4:2:2
Index : 4
Type : Video Capture
Pixel Format: 'NV16'
Name : Y/CbCr 4:2:2
Index : 5
Type : Video Capture
Pixel Format: 'YU12'
Name : Planar YUV 4:2:0
Index : 6
Type : Video Capture
Pixel Format: 'YU12'
Name : Planar YUV 4:2:0
Index : 7
Type : Video Capture
Pixel Format: 'YV12'
Name : Planar YVU 4:2:0
Index : 8
Type : Video Capture
Pixel Format: 'NV12'
Name : Y/CbCr 4:2:0
Index : 9
Type : Video Capture
Pixel Format: 'NV21'
Name : Y/CrCb 4:2:0
Index : 10
Type : Video Capture
Pixel Format: 'GREY'
Name : 8-bit Greyscale
Index : 11
Type : Video Capture
Pixel Format: 'Y444'
Name : 16-bit A/XYUV 4-4-4-4
Index : 12
Type : Video Capture
Pixel Format: 'NV24'
Name : Y/CbCr 4:4:4
Index : 13
Type : Video Capture
Pixel Format: 'JPEG' (compressed)
Name : JFIF JPEG
Index : 14
Type : Video Capture
Pixel Format: 'RGBP'
Name : 16-bit RGB 5-6-5
Index : 15
Type : Video Capture
Pixel Format: 'GRBG'
Name : 8-bit Bayer GRGR/BGBG
————————————————
版权声明:本文为CSDN博主「jin-fa」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/huang_165/article/details/86130288