• 借鉴已经有的lcd驱动配置

    这里借鉴:rv1106-evb-ext-rgb-v10.dtsi

  • DTS 中相关的几个节点:

    通过VOP(video output processor)视频输出处理器,rk内部处理模块。功能如下:

    1. 图层合成 — 支持多个显示图层(video layer、UI layer 等),将它们叠加合成输出
    2. 格式转换 — 将帧缓冲区的数据转换成显示接口所需的格式
    3. 输出路由 — 把信号路由到不同的显示接口(RGB、MIPI DSI、LVDS、HDMI 等)
    节点作用
    &vopVOP 模块本身,必须 status = "okay"
    &rgbRGB 并行接口(VOP 的输出之一)
    &route_rgb路由选择,告诉 VOP 把信号送到 RGB 接口
    &rgb_in_vopVOP 到 RGB 的输入连接
    &rgb {
    	status = "okay";
    	/**省略*/
    };
    &rgb_in_vop {
    	status = "okay";
    };
    
    &route_rgb {
    	status = "okay";
    };
    
    &sdio {
    	status = "disabled"; //有些sdmmc复用会影响,禁用掉
    };
    
    &vop {
    	status = "okay";
    };
    
    
  • 设备树下的rbg相关配置

    • clock-frequency 像素时钟频率

    • hactive 分辨率 行

    • hback-porch

    • hfront-porch

    • hsync-len

    • hsync-active

    • vactive 分辨率 高

    • vback-porch

    • vfront-porch

    • vsync-len

    • vsync-active

    • de-active

    • pixelclk-active

    /* 显示时序配置 */
    display-timings {
        native-mode = <&timing0>;         /* 指定默认时序 */
        timing0: timing0 {
             clock-frequency = <31250000>; /* 像素时钟频率 31.25MHz */
             hactive = <240>;               /* 水平有效像素 */
             vactive = <320>;               /* 垂直有效像素 */
             hfront-porch = <360>;          /* 水平前沿 */
             hback-porch = <360>;           /* 水平后沿 */
             hsync-len = <80>;              /* 水平同步宽度 */
             vfront-porch = <20>;           /* 垂直前沿 */
             vback-porch = <20>;            /* 垂直后沿 */
             vsync-len = <8>;               /* 垂直同步宽度 */
             hsync-active = <0>;             /* HSYNC 低电平有效 */
             vsync-active = <0>;             /* VSYNC 低电平有效 */
             de-active = <1>;                /* DE 高电平有效 */
             pixelclk-active = <1>;          /* 像素时钟上升沿采样 */
        };
    };
    
  • 纯色测试

    • 白色
    dd if=/dev/zero bs=4 count=$((240*320)) 2>/dev/null | tr '\0' '\377' > /dev/fb0
    
    • 黑色
    dd if=/dev/zero bs=4 count=$((240*320)) 2>/dev/null > /dev/fb0
    
    • 红色
    python3 - <<'PY' > /dev/fb0
    import sys
    w, h = 240, 320
    red   = b'\x00\x00\xff\x00'
    sys.stdout.buffer.write(red * (w * h))
    PY
    
    • 绿色
    python3 - <<'PY' > /dev/fb0
    import sys
    w, h = 240, 320
    green = b'\x00\xff\x00\x00'
    sys.stdout.buffer.write(green * (w * h))
    PY
    
    • 蓝色
    python3 - <<'PY' > /dev/fb0
    import sys
    w, h = 240, 320
    blue  = b'\xff\x00\x00\x00'
    sys.stdout.buffer.write(blue * (w * h))
    PY
    
  • modetest测试

    1. modetest -c
      
      [root@luckfox ]# modetest -c
      Connectors:
      id      encoder status          name            size (mm)       modes   encoders
      70      69      connected       DPI-1           43x57           1       69
        modes:
              index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot
        #0 240x320 68.98 240 282 292 302 320 328 332 336 7000 flags: nhsync, nvsync; type: preferred, driver
      
    2. modetest -M rockchip -s 70@66:240x320
      
      参数含义在你的场景中的具体作用
      modetestDRM测试工具本身调用用户态API (libdrm) 与内核通信
      -M rockchip指定驱动模块名强制直接打开Rockchip的DRM设备(如/dev/dri/card0),跳过之前那些漫长的i915/amdgpu等探测超时,实现瞬间执行
      -s设置显示模式 (Set Mode)核心动作:将指定的Connector(显示器接口)和CRTC(显示控制器)绑定起来,并启用显示输出
      70@66:240x320连接器ID @ CRTC ID : 分辨率70 是你的DPI屏幕接口,66 是显示控制器,强制以 240x320 分辨率输出
      -v详细模式 (Verbose)让程序在运行过程中打印每一帧的提交细节、像素格式转换、以及页面翻转(Fence)等内核事件
      trying to open device 'i915'...failed
      trying to open device 'amdgpu'...failed
      trying to open device 'radeon'...failed
      trying to open device 'nouveau'...failed
      trying to open device 'vmwgfx'...failed
      trying to open device 'omapdrm'...failed
      trying to open device 'exynos'...failed
      trying to open device 'tilcdc'...failed
      trying to open device 'msm'...failed
      trying to open device 'sti'...failed
      trying to open device 'tegra'...failed
      trying to open device 'imx-drm'...failed
      trying to open device 'rockchip'...done
      setting mode 240x320-68.98Hz on connectors 70, crtc 66
      failed to set gamma: Invalid argument
      

    看时钟

    # 挂载 debugfs(如果没挂载)
    mount -t debugfs none /sys/kernel/debug
    
    # 查看 VOP dclk 实际频率
    cat /sys/kernel/debug/clk/clk_summary | grep -i dclk
    
    # 或者看所有和显示相关的时钟
    cat /sys/kernel/debug/clk/clk_summary | grep -i "vop\|dclk\|rgb"