====摄像头接口====
[[http://cms.digi.com/resources/documentation/digidocs/embedded/dey/2.6/cc6ul/bsp_r_camera_6ul|点击查看官方英文文档]]
i.MX6UL处理器提供一个CSI接口。CC6UL SBC PRO可以通过扩展槽(8位数据总线和一条时钟线,三根同步信号线(PIXCLK,HSYNC,VSYNC),以及一对GPIO控制信号线和I2C1总线)来连接摄像头。
DEY的BSP支持Omnivision OV5460摄像头模型。
===内核配置===
您可以通过下面内核配置选项来管理CSI驱动支持以及Video4Linux (V4L2)拍照驱动。
* CSI camera support (CONFIG_VIDEO_MXC_CSI_CAMERA)
* OmniVision ov5640 camera support (CONFIG_MXC_CAMERA_OV5640_V2)
以上这两个选项在DEY当中默认开启
===内核驱动===
^ 文件 ^ 说明 ^
|[[https://github.com/digi-embedded/linux/blob/v4.14/dey-2.6/maint/drivers/media/platform/mxc/capture/mx6s_capture.c|drivers/media/platform/mxc/capture/mx6s_capture.c]] |CSI capture driver |
|[[https://github.com/digi-embedded/linux/blob/v4.14/dey-2.6/maint/drivers/media/platform/mxc/capture/ov5640_v2.c|drivers/media/platform/mxc/capture/ov5640_v2.c ]]|Omnivision OV5640 CSI camera sensor driver |
===设备树绑定和定制===
cc6ulsbcpro开发板所加载的设备树是imx6ul-ccimx6ulsbc-id135.dts所编译的设备树文件,该设备树主要继承了imx6ul-ccimx6ulsbc-wb.dts的相关定义。
由于单板机上CSI和USDHC2冲突,所以启用CSI之前,先禁掉microSD卡
/* USDHC2 (microSD, conflicts with eMMC) */
&usdhc2 {
pinctrl-assert-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
broken-cd; /* no carrier detect line (use polling) */
status = "disabled";
};
再把CSI和ov5640的设备树注释去掉,以启用它
&csi {
status = "okay";
};
/*
* CSI camera conflicts with microSD/eMMC.
* Before enabling the camera you need to disable
* usdhc2 node.
*/
&ov5640 {
status = "okay";
};
阅读BSP章节,发现上面节点描述符和设备树上有些出入,查上级设备树的引用imx6ul-ccimx6ulsbc.dtsi,原来主要定义在这里,默认已经有相关定义(除ov5640外,还有ov5642), 这些都挂在i2c1下。注意一般摄像头模组还要用到两个GPIO,控制电源和reset的,不同模组的使能电平是高是低可能不同,要根据spec来。
&i2c1 {
ov5640: ov5640@3c {
compatible = "ov5640";
reg = <0x3c>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_csi>;
clocks = <&clks IMX6UL_CLK_CSI>;
clock-names = "csi_mclk";
pwn-gpios = <&mca_ioexp_gpio 22 GPIO_ACTIVE_HIGH>; //注意你spec的电平定义
rst-gpios = <&mca_ioexp_gpio 31 GPIO_ACTIVE_LOW>; //默认设备树这两行引脚对应的gpio号不一样
csi_id = <0>;
mclk = <24000000>;
mclk_source = <0>;
status = "disabled";
digi,defer-probe;
port {
ov5640_ep: endpoint {
remote-endpoint = <&csi_ep>;
};
};
启用摄像头后,可以在log里看到下面信息(未插入摄像头时)
...
pxp-v4l2 pxp-v4l2: video output device registered as /dev/video0
pxp-v4l2 pxp-v4l2: initialized
CSI: capture device registered as /dev/video1
ov5640 0-003c: no sensor pwdn pin available
...