Edit online

DVP 配置

Read time: 3 minute(s)
DVP 包括以下配置内容:
  1. 内核配置

    DVP 驱动依赖 buf、CMA、V4L2 模块,所以需要提前打开。

    1. 在 SDK 根目录下,执行下列命令,进入 kernel 的功能配置界面:
      make kernel-menuconfig

      或使用简写命令

      make km
    2. 在内核配置界面,按如下选择:

      Linux
          Memory Management options
               [*] Contiguous Memory Allocator
      
    3. 设置 CMA 区域的大小,在内核配置的另外一个地方,如下配置为 16MB:

      Linux
          Library routines
              [*] DMA Contiguous Memory Allocator
              (16)  Size in Mega Bytes
      
    4. 打开 DMA-BUF

      在 SDK 根目录下执行 make kernel-menuconfigmake me,进入 kernel 的功能配置,按如下选择:

      Linux
          Device Drivers
              DMABUF options
                  [*] Explicit Synchronization Framework
                  [*]   Sync File Validation Framework
                  [*] userspace dmabuf misc driver
                  [*] DMA-BUF Userland Memory Heaps
                      [*]   DMA-BUF CMA Heap
      
    5. 打开 V4L2

      在 SDK 根目录下执行 make kernel-menuconfigmake me,进入 kernel 的功能配置,按如下选择:

      Linux
          Device Drivers
               Multimedia support
                  Media core support
                      <*> Video4Linux core

      打开 V4L2 的相关选项:

      Linux
          Device Drivers
               Multimedia support
                  Video4Linux options
                      [*] V4L2 sub-device userspace API
                      [*] Enable advanced debug functionality on V4L2 drivers
    6. 打开 DVP

      在 SDK 根目录下执行 make kernel-menuconfigmake me,进入 kernel 的功能配置,按如下选择:

      Linux
          Device Drivers
               Multimedia support
                  Media drivers
                      [*] V4L platform devices
                          <*>   ArtInChip Digital Video Port Support
  2. DTS 参数配置

    DTS 分别存放在 common/board/ 目录中,其中 board 目录存放了 sensor 配置以及 DVP 的关联配置。

    D211 配置

    common/d211.dtsi 中的参数配置:
    dvp0: dvp@18830000 {
        #address-cells = <1>;
        #size-cells = <0>;
        compatible = "artinchip,aic-dvp-v1.0";
        reg = <0x0 0x18830000 0x0 0x1000>;
        interrupts-extended = <&plic0 57 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&cmu CLK_DVP>;
        clock-rate = <200000000>;
        resets = <&rst RESET_DVP>;
    };
    xxx/board.dts 中的配置参数:
    &dvp0 {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&dvp_pins>;        /* dvp 接口引脚 */
    
        port@0 {
            reg = <0>;
            dvp0_in: endpoint {
                remote-endpoint = <&ov5640_out>;
    /*          bus-type = <6>; /* V4L2_FWNODE_BUS_TYPE_BT656 */
                bus-width = <8>;
                hsync-active = <1>;
                vsync-active = <1>;
                field-even-active = <1>;
                pclk-sample = <1>;
            };
        };
    };
    DVP 驱动支持标准的 V4L2 参数,如上面的 bus-type、bus-type、hsync-active。关于更完整的参数定义,详见 Linux 代码 drivers/media/v4l2-core/v4l2-fwnode.c 中的 v4l2_fwnode_endpoint_parse_parallel_bus() 描述。