Skip to content

泰山派_移植ov8858摄像头

内核中已经适配了ov8858的驱动源码,只需要

  • 开启对应的驱动编译选项
  • 配置设备树
/home/shelton/Workspaces/source/sdk/rockchip/rk3566_tspi/tspi_linux_sdk_repo_20240131/kernel/drivers/media/i2c/ov8858.c

开启OV5695驱动编译选项

kernel kconfig

shell
#选中预选的配置
source buildroot/build/envsetup.sh
# 所有配置项的目录
#/home/shelton/Workspaces/source/sdk/rockchip/rk3566_tspi/tspi_linux_sdk_repo_20240131/buildroot/configs

# 进入图形化配置
make menuconfig
# 65 rockchip_rk3566_defconfig

#保存配置
make savedefconfig

此时kernel的 kconfig 会加载默认的配置项tspi_linux_sdk_repo_20240131/kernel/arch/arm64/configs/rockchip_linux_defconfig

  • kconfig由多个配置文件组合而成,因此可以直接在rockchip_linux_defconfig中添加配置

rockchip_linux_defconfig 中添加 CONFIG_VIDEO_OV8858=y

shell
# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
CONFIG_VIDEO_OV5695=y
#...
CONFIG_VIDEO_OV8858=y

此时tspi_linux_sdk_repo_20240131/kernel/arch 中的 Makefile的这个目标就生效了

shell
obj-$(CONFIG_VIDEO_OV8858)	+= ov8858.o

tspi_linux_sdk_repo_20240131/kernel/drivers/media/i2c 中出现 ov8858.o 即为添加成功

修改设备树

设备树的路径为

shell
/home/shelton/Workspaces/source/sdk/rockchip/rk3566_tspi/tspi_linux_sdk_repo_20240131/kernel/arch/arm64/boot/dts/rockchip

创建ov8858对应的设备树

基于ov5695的设备树 tspi-rk3566-csi-v10.dtsi 修改 数据链路

这是一个真实、对称、可验证的硬件连接

Sensor → CSI-2 DPHY → ISP 的数据通路

[ov8858] ──⇄── [csi2_dphy0] ──⇄── [rkisp_vir0]
              (in/out endpoints)

remote-endpoint 的指向如上图

shell
//摄像头D-PHY接口
&csi2_dphy0 {
	status = "okay";
	ports {
		port@0 {
			reg = <0>;
			dphy0_in: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&ov8858_out>;
				data-lanes = <1 2 3 4>;
			};
		};

		port@1 {
			reg = <1>;
			dphy0_out: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&isp0_in>;
			};
		};
	};
};

//图像处理接口
&rkisp_vir0 {
	status = "okay";
	port {
		isp0_in: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&dphy0_out>;
		};
	};
};

&i2c4 {
		port {
			ov8858_out: endpoint {
				remote-endpoint = <&dphy0_in>; 
				data-lanes = <1 2 3 4>;  // 2lane为 <1 2>, 4lane为 <1 2 3 4>
			};
		};
	};
};

复位引脚 高电平有效

复位引脚 高电平有效 #_Later

镜头参数

/home/shelton/Workspaces/source/sdk/rockchip/rk3566_tspi/tspi_linux_sdk_repo_20240131/external/camera_engine_rkaiq/iqfiles/isp21

./camera_engine_rkaiq/tests/rkisp_demo/demo/rkisp_demo.cpp

完整设备树代码

shell

/*********************************************************************
 *           立创开发板不靠卖板赚钱,以培养中国工程师为己任  
 *         泰山派软硬件资料与相关扩展板软硬件资料官网全部开源
 *                      开发板官网:www.lckfb.com            
 *                     立创论坛:oshwhub.com/forum           
 *            关注B站:【立创开发板】,掌握我们的最新动态!  
 *********************************************************************
 * 文件名:tspi-rk3566-csi-v10
 * 描述:mipi 摄像头
 * 更新:
 * 时间          作者           联系           说明
 * 2023-09-13   吴才成    1378913492@qq.com   v1.0.0
 *********************************************************************/

//phy u序列
&combphy1_usq {
	status = "okay";
};

//phy P序列
&combphy2_psq {
	status = "okay";
};

//dphy硬件
&csi2_dphy_hw {
	status = "okay";
};
//摄像头D-PHY接口
&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 = <&ov8858_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>;
			};
		};
	};
};

//摄像头D-PHY接口
&csi2_dphy1 {
	status = "disabled";

	/*
	 * dphy1 only used for split mode,
	 * can be used  concurrently  with dphy2
	 * 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>;

			dphy1_in: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&ov8858_out>;
				data-lanes = <1 2>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			dphy1_out: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&isp0_in>;
			};
		};
	};
};
//摄像头D-PHY接口
&csi2_dphy2 {
	status = "disabled";

	/*
	 * dphy2 only used for split mode,
	 * can be used  concurrently  with dphy1
	 * 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>;

			dphy2_in: endpoint@1 {
				reg = <1>;
				//remote-endpoint = <&gc5025_out>;
				data-lanes = <1 2>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			dphy2_out: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&mipi_csi2_input>;
			};
		};
	};
};



&mipi_csi2 {
	status = "disabled";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_csi2_input: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&dphy2_out>;
				data-lanes = <1 2>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_csi2_output: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&cif_mipi_in>;
				data-lanes = <1 2>;
			};
		};
	};
};

//Rockchip Camera Interface
&rkcif {
	status = "disabled";
};

//dvp接口摄像头
&rkcif_dvp {
	status = "disabled";

	port {
		/* Parallel bus endpoint */
		dvp_in_bcam: endpoint {
			// remote-endpoint = <&gc2145_out>;
			bus-width = <8>;
			vsync-active = <0>;
			hsync-active = <1>;
		};
	};
};

//LVDS接口摄像头
&rkcif_mipi_lvds {
	status = "disabled";

	port {
		cif_mipi_in: endpoint {
			remote-endpoint = <&mipi_csi2_output>;
			data-lanes = <1 2>;
		};
	};
};

//摄像头内存管理
&rkcif_mmu {
	status = "disabled";
};

//硬件图像处理器模块
&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 = <&dphy0_out>;
		};
	};
};

&i2c4 {
	/* i2c4 sda conflict with camera pwdn */
	status = "okay";
	ov8858: ov8858@36 {
		status = "okay";
		compatible = "ovti,ov8858";
		reg = <0x36>;
		clocks = <&cru CLK_CIF_OUT>;
		clock-names = "xvclk";
		power-domains = <&power RK3568_PD_VI>;
		pinctrl-names = "default";
		pinctrl-0 = <&cif_clk>;
        reset-gpios = <&gpio4 RK_PB5 GPIO_ACTIVE_HIGH>;
		pwdn-gpios = <&gpio4 RK_PB4 GPIO_ACTIVE_HIGH>;
		power-gpios = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
        rockchip,camera-module-name = "HS5885-BNSM1018-V01";
		rockchip,camera-module-lens-name = "default";
		port {
			ov8858_out: endpoint {
				remote-endpoint = <&dphy0_in>;
				data-lanes = <1 2 3 4>;
			};
		};
	};
};
最近更新