rk3568 适配摄像头 (mipi 单摄)
MIPI CSI(Mobile Industry Processor Interface Camera Serial Interface)是一种用于移动设备的高速串行接口标准,用于连接图像传感器和图像处理器。MIPI CSI接口使用差分信号传输技术,将数据分为数据线和时钟线两部分,以提高传输速度和抗干扰能力。数据线和时钟线通过MIPI D-PHY(Physical Layer)进行物理层传输,D-PHY支持多种传输速率和数据格式。
提示:rk3568 支持 4lane 的mipi CSI,且可拆分成 2+2模式。
文章目录
- rk3568 适配摄像头 (mipi 单摄)
- 圈重点 看想学
- 1. 核查硬件,匹配摄像头
- 1.1 内核设备树适配gc8034
- 1.2 内核设备树适配 ov5695
- 1.3 gc8034 和ov5695自动匹配
- 2 调试过程问题分析
- 总结
圈重点 看想学
a) 适配mipi摄像头 gc8034
b) 适配mipi摄像头 ov5695
1. 核查硬件,匹配摄像头
核查原理图需要匹配摄像头的供电 avdd、vdd、vcc,控制信号 pwdn、reset、enable,主时钟(rk3568输出时钟),I2C总线和 mipi信号通道。此处不在赘述,需要了解的小伙伴请关注博主的下一篇博文。
核查rk3568芯片手册发现仅有一个CSI 4 lane,可以拆分成 2 lane x 2分。匹配摄像头方式如下:
1.1 内核设备树适配gc8034
&i2c2 {
status = "okay";
pinctrl-0 = <&i2c2m1_xfer>;
/* full mode: lane0-3 */
gc8034: gc8034@37 {
compatible = "galaxycore,gc8034";
status = "okay";
reg = <0x37>;
clocks = <&cru CLK_CIF_OUT>;
clock-names = "xvclk";
power-domains = <&power RK3568_PD_VI>;
pinctrl-names = "default";
pinctrl-0 = <&cif_clk>;
reset-gpios = <&gpio3 RK_PA6 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio4 RK_PB2 GPIO_ACTIVE_LOW>;
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "RK-CMK-8M-2-v1";
rockchip,camera-module-lens-name = "CK8401";
port {
gc8034_out: endpoint {
remote-endpoint = <&dphy0_in>;
data-lanes = <1 2 3 4>;
};
};
};
};
&csi2_dphy_hw {
status = "okay";
};
&csi2_dphy0 {
status = "okay";
/*
* dphy0 only used for full mode,
* full mode and split mode are mutually exclusive
*/
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
dphy0_in: endpoint@1 {
reg = <1>;
remote-endpoint = <&gc8034_out>;
data-lanes = <1 2 3 4>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
dphy0_out: endpoint@1 {
reg = <1>;
remote-endpoint = <&isp0_in_dphy0>;
};
};
};
};
&rkisp {
status = "okay";
};
&rkisp_mmu {
status = "okay";
};
&rkisp_vir0 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp0_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&dphy1_out>;
};
isp0_in_dphy0: endpoint@1 {
reg = <1>;
remote-endpoint = <&dphy0_out>;
};
};
};
1.2 内核设备树适配 ov5695
&i2c2 {
status = "okay";
pinctrl-0 = <&i2c2m1_xfer>;
ov5695: ov5695@36 {
status = "okay";
compatible = "ovti,ov5695";
reg = <0x36>;
clocks = <&cru CLK_CAM0_OUT>;
clock-names = "xvclk";
power-domains = <&power RK3568_PD_VI>;
pinctrl-names = "default";
pinctrl-0 = <&cam_clkout0>;
reset-gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_HIGH>;
pwdn-gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>;
/*power-gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>;*/
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "TongJu";
rockchip,camera-module-lens-name = "CHT842-MD";
port {
ov5695_out: endpoint {
remote-endpoint = <&mipi_in_ucam0>;
data-lanes = <1 2>;
};
};
};
};
&csi2_dphy0 {
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 = <&ov5695_out>;
data-lanes = <1 2>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
csidphy_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&isp0_in>;
};
};
};
};
&rkisp {
status = "okay";
};
&rkisp_mmu {
status = "okay";
};
&rkisp_vir0 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp0_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&csidphy_out>;
};
};
};
1.3 gc8034 和ov5695自动匹配
gc8034: gc8034@37 {
compatible = "galaxycore,gc8034";
reg = <0x37>;
clocks = <&cru CLK_CAM0_OUT>;
clock-names = "xvclk";
power-domains = <&power RK3568_PD_VI>;
pinctrl-names = "default";
pinctrl-0 = <&cam_clkout0>;
reset-gpios = <&gpio2 RK_PD5 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_LOW>;
rockchip,grf = <&grf>;
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "RK-CMK-8M-2-v1";
rockchip,camera-module-lens-name = "CK8401";
port {
gc8034_out: endpoint {
remote-endpoint = <&mipi_in_ucam0>;
data-lanes = <1 2 3 4>;
};
};
};
ov5695: ov5695@36 {
status = "okay";
compatible = "ovti,ov5695";
reg = <0x36>;
clocks = <&cru CLK_CAM0_OUT>;
clock-names = "xvclk";
power-domains = <&power RK3568_PD_VI>;
pinctrl-names = "default";
pinctrl-0 = <&cam_clkout0>;
reset-gpios = <&gpio2 RK_PD5 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio4 RK_PA6 GPIO_ACTIVE_HIGH>;
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "TongJu";
rockchip,camera-module-lens-name = "CHT842-MD";
port {
ov5695_out: endpoint {
remote-endpoint = <&mipi_in_ucam1>;
data-lanes = <1 2>;
};
};
};
};
&csi2_dphy_hw {
status = "okay";
};
&csi2_dphy0 {
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
mipi_in_ucam1: endpoint@1 {
reg = <1>;
remote-endpoint = <&gc8034_out>;
data-lanes = <1 2 3 4>;
};
mipi_in_ucam2: endpoint@2 {
reg = <2>;
remote-endpoint = <&ov5695_out>;
data-lanes = <1 2>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
csidphy_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&isp0_in>;
};
};
};
};
&rkisp {
status = "okay";
};
&rkisp_mmu {
status = "okay";
};
&rkisp_vir0 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp0_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&csidphy_out>;
};
};
};
2 调试过程问题分析
本篇文章简单讲述摄像头匹配方法,文章篇幅过大不利于阅读,请关注原作的下一篇。
总结
活学活用,欢迎诸位订阅原作者。