DTS中video-interfaces接口详解
视频数据管道通常由外部设备组成,例如通过I2C、SPI或UART总线控制的摄像机传感器,以及SoC内部IP块(包括视频DMA引擎和视频数据处理器)。
SoC内部块由DT节点描述,与其他SoC块放置方式类似。外部设备表示为它们各自总线控制器节点的子节点,例如I2C。
所有视频设备上的数据接口都由它们的子“port”节点描述。端口的配置取决于参与数据传输的其他设备,并由“endpoint”子节点描述。
device {
    ...
    ports {
        #address-cells = <1>;
        #size-cells = <0>;
        port@0 {
            ...
            endpoint@0 { ... };
            endpoint@1 { ... };
        };
        port@1 { ... };
    };
};
如果一个端口可以配置为与同一总线上的多个远程设备一起工作,则必须为每个端口提供一个“endpoint”子节点。如果一个设备节点中有多个端口,或者端口上有多个端点,或者端口节点需要与选定的硬件接口相关联,则使用使用“#address-cells”、“#size-cells”和“reg”属性的常见方案。
所有“port”节点都可以分组再 可选的“port”节点下,该节点允许独立为“端口”和“端点”节点以及设备可能拥有的任何子设备节点指定#address-cells、#size-cells属性。
两个“endpoint” 节点通过它们的“remote-endpoint'”相互链接。设备的端点子节点包含配置此设备所需的所有属性,以便与其他设备进行数据交换。在大多数情况下,对等“端点”节点上的属性是相同的,但是当两个设备之间总线上有任何信号修改时,它们可能需要不同,例如线路上有逻辑信号逆变器。
它允许端口上的多个端点同时处于活动状态,而设备支持这种状态。例如,当一个设备的数据接口被划分为多个数据总线时,例如16位输入端口被划分为两个单独的ITU-R BT.656 8位总线。在这种情况下,可以使用总线宽度和数据转移属性为每个端点节点(逻辑总线)分配物理数据线。
必要属性Required properties
If there is more than one 'port' or more than one 'endpoint' node or 'reg' property is present in port and/or endpoint nodes the following properties are required in a relevant parent node:
如果存在多个“port”或多个“endpoint”节点或“reg”属性,则在相关父节点中需要以下属性:
 - #address-cells : number of cells required to define port/endpoint identifier, should be 1.
 - #size-cells    : should be zero.
非必要属性Optional endpoint properties
- remote-endpoint: 远端设备节点 phandle to an 'endpoint' subnode of a remote device node.
- slave-mode: 一个布尔属性,指示链接在从属模式下运行。未指定此属性时的默认值为主模式。在从模式下,水平和垂直同步信号由主设备(数据接收器)提供给从设备(数据源)。在主模式下,数据源设备也是同步信号的源。
- bus-width: 总线位宽,适用于并行总线。
- data-shift: 在并行数据总线上,如果指定了bus-width,则可以使用data-shift来指定使用哪些数据,例如。“总线带宽= < 8 >;data-shift=<2>;"表示使用了2-8位的数据。 
- hsync-active: HSYNC信号的活动状态,低/高分别为0/1。
- vsync-active: VSYNC信号的活动状态,低/高分别为0/1。
注意,如果没有指定HSYNC和VSYNC极性,可能需要在支持的情况下进行嵌入式同步。
- data-active: 指定数据行极性。 
- field-even-active: 场信号电平均匀时场数据传输。
- pclk-sample: 采样数据上的上升(1)或下降(0)边缘的像素时钟信号。
- sync-on-green-active: 同步绿色(SoG)信号的激活状态,低/高分别为0/1。 
- data-lanes: 在mipi总线下,数据lane的指定。a
- clock-lanes:  在mipi总线下,时钟lane的指定。- clock-noncontinuous: 允许非连续时钟
- link-frequencies: 总线频率
- lane-polarities: lean极性
例子Example
下面的示例代码片段描述了两个数据管道。ov772x和imx074分别是带有并行和串行(MIPI CSI-2)视频总线的摄像机传感器。两个传感器都位于I2C控制总线上,对应于i2c0控制器节点。ov772x传感器直接连接到ceu0视频主机接口。imx074通过MIPI CSI-2接收器(csi2)连接到ceu0。ceu0有一个(单个)DMA引擎将捕获的数据写入内存。ceu0节点有一个单一的“端口”节点,这可能表明在任何时候只有以下数据管道中的一个可以活动:ov772x -> ceu0或imx074 -> csi2 -> ceu0。
   ceu0: ceu@0xfe910000 {
        compatible = "renesas,sh-mobile-ceu";
        reg = <0xfe910000 0xa0>;
        interrupts = <0x880>;
        mclk: master_clock {
            compatible = "renesas,ceu-clock";
            #clock-cells = <1>;
            clock-frequency = <50000000>;   /* Max clock frequency */
            clock-output-names = "mclk";
        };
        port {
            #address-cells = <1>;
            #size-cells = <0>;
            /* Parallel bus endpoint /
            ceu0_1: endpoint@1 {
                reg = <1>;      / Local endpoint # /
                remote = <&ov772x_1_1>; / Remote phandle /
                bus-width = <8>;    / Used data lines /
                data-shift = <2>;   / Lines 9:2 are used */
                /* If hsync-active/vsync-active are missing,
                   embedded BT.656 sync is used /
                hsync-active = <0>; / Active low /
                vsync-active = <0>; / Active low /
                data-active = <1>;  / Active high /
                pclk-sample = <1>;  / Rising */
            };
            /* MIPI CSI-2 bus endpoint */
            ceu0_0: endpoint@0 {
                reg = <0>;
                remote = <&csi2_2>;
            };
        };
    };
i2c0: i2c@0xfff20000 {
        ...
        ov772x_1: camera@0x21 {
            compatible = "ovti,ov772x";
            reg = <0x21>;
            vddio-supply = <®ulator1>;
            vddcore-supply = <®ulator2>;
            clock-frequency = <20000000>;
            clocks = <&mclk 0>;
            clock-names = "xclk";
            port {
                /* With 1 endpoint per port no need for addresses. /
                ov772x_1_1: endpoint {
                    bus-width = <8>;
                    remote-endpoint = <&ceu0_1>;
                    hsync-active = <1>;
                    vsync-active = <0>; / Who came up with an
                                   inverter here ?... */
                    data-active = <1>;
                    pclk-sample = <1>;
                };
            };
        };
            imx074: camera@0x1a {
            compatible = "sony,imx074";
            reg = <0x1a>;
            vddio-supply = <®ulator1>;
            vddcore-supply = <®ulator2>;
            clock-frequency = <30000000>;   /* Shared clock with ov772x_1 /
            clocks = <&mclk 0>;
            clock-names = "sysclk";     / Assuming this is the
                               name in the datasheet */
            port {
                imx074_1: endpoint {
                    clock-lanes = <0>;
                    data-lanes = <1 2>;
                    remote-endpoint = <&csi2_1>;
                };
            };
        };
    };
  csi2: csi2@0xffc90000 {
        compatible = "renesas,sh-mobile-csi2";
        reg = <0xffc90000 0x1000>;
        interrupts = <0x17a0>;
        #address-cells = <1>;
        #size-cells = <0>;
        port@1 {
            compatible = "renesas,csi2c";   /* One of CSI2I and CSI2C. /
            reg = <1>;          / CSI-2 PHY #1 of 2: PHY_S,
                               PHY_M has port address 0,
                               is unused. /
            csi2_1: endpoint {
                clock-lanes = <0>;
                data-lanes = <2 1>;
                remote-endpoint = <&imx074_1>;
            };
        };
        port@2 {
            reg = <2>;          / port 2: link to the CEU */
            csi2_2: endpoint {
                remote-endpoint = <&ceu0_0>;
            };
        };
    };
————————————————
版权声明:本文为CSDN博主「龙图腾」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/dragon101788/article/details/99445027
Port Binding端口绑定
vi {
num-channels = <1>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
    reg = <0>;
    liimx185_vi_in0: endpoint {
        port-index = <2>;
        bus-width = <4>;
        remote-endpoint = <&liimx185_csi_out0>;
      };
  };
};
};
nvcsi {
num-channels = <1>;
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
ports {
    #address-cells = <1>;
    #size-cells = <0>;
    port@0 {
        reg = <0>;
        liimx185_csi_in0: endpoint@0 {
            port-index = <0>;
            bus-width = <4>;
            remote-endpoint = <&liimx185_imx185_out0>;
        };
    };
    port@1 {
        reg = <1>;
        liimx185_csi_out0: endpoint@1 {
            remote-endpoint = <&liimx185_vi_in0>;
        };
    };
};
};
};
端口绑定属性是:
function
description
port
指定媒体填充端口连接。 所有成像器设备都有一个介质垫,用于绑定与VI的连接。
port-index
定义传感器端口连接。 对于成像器设备,例如聚焦器或闪光灯,不需要该字段。有关更多信息,请参阅端口索引。
bus-width
通过识别连接到传感器的CSI通道的数量来定义总线宽度。
remote-endpoint
定义绑定两个端口的标签。 绑定期望一个端口用于接收器,另一个端口用于源。
验证相机接口绑定
执行以下命令
//if have sudo apt-get install media-player-info
sudo media-ctl -p -d /dev/media0
对于本身不带该命令的系统可以通过apt-get install进行安装:
sudo apt-get install v4l-utils
返回的输出类似于以下内容:
Media controller API version 0.1.0
Media device information
driver tegra-vi4
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 0.0.0
Device topology
- entity 1: 150c0000.nvcsi-0 (2 pads, 2 links) - type V4L2 subdev subtype Unknown flags 0 device node name /dev/v4l-subdev0- pad0: Sink 
 <- "imx185 30-001a":0 [ENABLED]
 pad1: Source
 -> "vi-output, imx185 30-001a":0 [ENABLED]
- entity 2: imx185 30-001a (1 pad, 1 link) - type V4L2 subdev subtype Sensor flags 0 device node name /dev/v4l-subdev1- pad0: Source 
 [fmt:SRGGB12/1920x1080 field:none]
 -> "150c0000.nvcsi-0":0 [ENABLED]
- entity 3: vi-output, imx185 30-001a (1 pad, 1 link) - type Node subtype V4L flags 0 device node name /dev/video0- pad0: Sink 
 <- "150c0000.nvcsi-0":1 [ENABLED]
作者:真全
链接:https://www.jianshu.com/p/e80a9e60a765
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。