DTS配置
配置isp节点
1. cif_isp0: cif_isp@ff910000 {
compa
tible = "rockchip,rk3399-cif-isp";
rockchip,grf = <&grf>;
reg = <0x0 0xff910000 0x0 0x4000>, <0x0 0xff968000 0x0 0x8000>;
reg-names = "register", "dsihost-register";
clocks =
<&cru ACLK_ISP0_NOC>, <&cru ACLK_ISP0_WRAPPER>,
<&cru HCLK_ISP0_NOC>, <&cru HCLK_ISP0_WRAPPER>,
<&cru SCLK_ISP0>, <&cru SCLK_DPHY_RX0_CFG>,
<&cru SCLK_CIF_OUT>, <&cru SCLK_CIF_OUT>,
<&cru SCLK_MIPIDPHY_REF>;
clock-names =
"aclk_isp0_noc", "aclk_isp0_wrapper",
"hclk_isp0_noc", "hclk_isp0_wrapper",
"clk_isp0", "pclk_dphyrx",
"clk_cif_out", "clk_cif_pll",
"pclk_dphy_ref";
interrupts =
;
interrupt-names = "cif_isp10_irq";
power-domains = <&power RK3399_PD_ISP0>;
rockchip,isp,iommu-enable = <1>;
iommus = <&isp0_mmu>;
status = "disabled";
};
&isp0 {
status = "okay";
};
&isp0_mmu {
status = "okay";
};
&cif_isp0 {
rockchip,camera-modules-attached = <&camera0>;
status = "okay";
};
设置CPU MCLK引脚功能
1. &pinctrl {
/* */
cam_mclk {
cam_default_pins: cam-default-pins {
rockchip,pins = <2 11 RK_FUNC_3 &pcfg_pull_none>;
};
};
};
在i2c上配置camera节点,mipi0 camera连接到i2c1上
1. &i2c1 {
status = "okay"; /* 使能i2c1 */
/*
* 一般写成cameraX:camera-module@ID,其中X为序号,ID为camera的7bit I2C地址
* camera0表示节点名,绑定isp节点时,将camera0 attach到isp0
*/
camera0: camera-module@10 {
status = "okay";
compatible = "omnivision,ov9750-v4l2-i2c-subdev";
reg = <0x10>; /* 7bit I2C地址 */
device_type = "v4l2-i2c-subdev"; /* 无需修改 */
clocks = <&cru SCLK_CIF_OUT>; /* 无需修改,时钟源选择 */
clock-names = "clk_cif_out"; /* 无需修改,时钟源名字 */
pinctrl-names = "default"; /* 无需修改,通过pinctrl配置MCLK引脚 */
pinctrl-0 = <&cam_default_pins>; /* 无需修改,与上文的pinctrl定义一致 */
rockchip,pd-gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_LOW>; /* PD管脚分配及有效电平 */
rockchip,rst-gpio = <&gpio4 RK_PD2 GPIO_ACTIVE_LOW>; /* RST管脚分配及有效电平 */
rockchip,camera-module-mclk-name = "clk_cif_out"; /* 无需修改 */
rockchip,camera-module-facing = "back"; //前后置配置
rockchip,camera-module-name = "MDG001"; //Camera 模组名称
rockchip,camera-module-len-name = "NONE"; //Camera 模组镜头
rockchip,camera-module-fov-h = "80"; //模组水平可视角度配置
rockchip,camera-module-fov-v = "65"; //模组垂直可视角度配置
rockchip,camera-module-orientation = <0>; //模组角度设置
rockchip,camera-module-iq-flip = <0>; //IQ 上下翻转
rockchip,camera-module-iq-mirror = <0>; //IQ 左右镜像
//以上 2 个属性控制摄像头的效果参数镜像配置,一般都是设置成 0,但是发现以下现象:拍摄白墙,图片的上半部偏色与下半部偏色不一致,或者左右半部偏不一致,即可以将这2个属性置成1。
rockchip,camera-module-flip = <1>;
rockchip,camera-module-mirror = <1>;
//以上 2 个属性控制摄像头驱动中的镜像配置,如果图像旋转 180 度,可以将这 2 个属性修改成相反的值即可旋转 180。
rockchip,camera-module-defrect0 = <1280 960 0 0 1280 960>; //根据摄像头分辨率进行设置
rockchip,camera-module-flash-support = <0>; //闪光灯支持
rockchip,camera-module-mipi-dphy-index = <0>; //mipi口配置,根据物理连接定义
as-master = <0>;
};
};
驱动说明
与摄像头相关的代码目录如下:
1. drivers/media/i2c/soc_camera/rockchip
|-- ov9750_v4l2-i2c-subdev.c // OV9750驱动
|-- ov_camera_module.c // OV系列公共函数
|-- ov_camera_module.h //
|-- rk_camera_mclk.c // RK Camera MCLK时钟信号管理
|-- rk_camera_mclk.h
|-- rk_camera_module.c // RK 系列公共函数
`-- rk_camera_module_version.h //模块版本信息
`