Linux v4l2子系统(5):MIPI DPHY
1 CSI2 DPHY框架图
2 CSI2 DPHY的DTS配置和初始化
csi2_dphy0_hw中定义了DPHY的硬件信息:
csi2_dphy0_hw: csi2-dphy0-hw@fedc0000 {
compatible = "rockchip,rk3588-csi2-dphy-hw";
reg = <0x0 0xfedc0000 0x0 0x8000>;
clocks = <&cru PCLK_CSIPHY0>;
clock-names = "pclk";
resets = <&cru SRST_CSIPHY0>, <&cru SRST_P_CSIPHY0>;
reset-names = "srst_csiphy0", "srst_p_csiphy0";
rockchip,grf = <&mipidphy0_grf>;
rockchip,sys_grf = <&sys_grf>;
status = "disabled";
};
分配struct csi2_dphy_hw结构体,并填充初始化:
rockchip_csi2_dphy_hw_driver ->rockchip_csi2_dphy_hw_probe
csi2_dphy0作如下定义:
- 定义所使用的硬件DPHY资源:csi2_dphy0_hw。
- 定义了Media Graph上下游:port@0作为Sink Pad,是MIPI Camera;port@1作为Source Pad,是CSI2 Host。
csi2_dphy0: csi2-dphy0 {
compatible = "rockchip,rk3568-csi2-dphy";
rockchip,hw = <&csi2_dphy0_hw>;
status = "disabled";
};
&csi2_dphy0 {
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
mipidphy0_in_ucam0: endpoint@1 {
reg = <1>;
remote-endpoint = <&ov5695_out_3>;
data-lanes = <1 2>;
};
mipidphy0_in_ucam0_ov13850: endpoint@2 {
reg = <2>;
remote-endpoint = <&ov13850_out_3>;--来自于ov13850_3的ov13850_out_3。
data-lanes = <1 2 3 4>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
csidphy0_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&mipi2_csi2_input>;--输出到mipi2_csi2的mipi2_csi2_input。
};
};
};
};
rockchip_csi2_dphy_probe进行CSI2 Host初始化:
- 获取DPHY硬件配置信息。
- 注册CSI2 Host的v4l2 Subdev设备。
- 遍历port及其endpoint注册设备。
rockchip_csi2_dphy_driver
->rockchip_csi2_dphy_probe
->rockchip_csi2_dphy_attach_hw--读取"rockchip,hw"节点,获取DPHY硬件struct csi2_dphy_hw结构体数据。
->v4l2_subdev_init--初始化subdev,操作函数集为csi2_dphy_subdev_ops。
->rockchip_csi2dphy_media_init--两个pad,一个Sink,一个Source。
->media_entity_pads_init--创建Media Pad。
->v4l2_async_notifier_init
->v4l2_async_notifier_parse_fwnode_endpoints_by_port--解析/csi2-dphy0/ports/port@0/的endpoint,
->__v4l2_async_notifier_parse_fwnode_ep
->v4l2_async_notifier_fwnode_parse_endpoint--遍历port下所有的endpoint。
->fwnode_graph_get_remote_port_parent--获取remote-endpoint。
->v4l2_fwnode_endpoint_alloc_parse
->rockchip_csi2_dphy_fwnode_parse
->v4l2_fwnode_endpoint_free
->v4l2_async_notifier_add_subdev
->v4l2_async_subdev_notifier_register
->v4l2_async_register_subdev
CSI2 DPHY的Subdev设备操作函数集为:
static const struct v4l2_subdev_core_ops csi2_dphy_core_ops = {
.s_power = csi2_dphy_s_power,
};
static const struct v4l2_subdev_video_ops csi2_dphy_video_ops = {
.g_frame_interval = csi2_dphy_g_frame_interval,
.s_stream = csi2_dphy_s_stream,
};
static const struct v4l2_subdev_pad_ops csi2_dphy_subdev_pad_ops = {
.set_fmt = csi2_dphy_get_set_fmt,
.get_fmt = csi2_dphy_get_set_fmt,
.get_selection = csi2_dphy_get_selection,
.get_mbus_config = csi2_dphy_g_mbus_config,
};
static const struct v4l2_subdev_ops csi2_dphy_subdev_ops = {
.core = &csi2_dphy_core_ops,
.video = &csi2_dphy_video_ops,
.pad = &csi2_dphy_subdev_pad_ops,
};
DPHY设备:
- 对应的v4l2设备为/dev/v4l-subdev1,对应操作函数转到对csi2_dphy_subdev_ops的调用。
- 在Media子系统中对应的Entity为rockchip-csi2-dphy0。
- rockchip-csi2-dphy0有两个Pad:0为Sink Pad,1位Source Pad。
联系方式:arnoldlu@qq.com