V3s 屏幕LCD驱动总结

使用V3s做项目一段时间了,做开发难免会做UI相关的开发,移植linux5.2.y分支后屏幕总是出现闪烁条纹,同样的7寸液晶下1024*600 和 800*480 的屏幕都试过;使用逻辑分析仪查看LCD_CLK 总是在25Mhz ,但是在Uboot 启动后加载的LCD 驱动CLK 莫名的 33.3Mhz;翻看相关论坛早已有同行踩坑,关于V3s display-engine/display_clocks /mixer0和tcon0 有关lcd时钟配置的一些问题 / 全志 SOC / WhyCan Forum(哇酷开发者社区) 

找到修改 内核linux-5.2.y/drivers/gpu/drm/sun4i/sun4i_tcon.c , 488 行 改之,重新编译即可;

static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
                                     const struct drm_encoder *encoder,
                                     const struct drm_display_mode *mode)
{
        struct drm_connector *connector = sun4i_tcon_get_connector(encoder);
        struct drm_display_info display_info = connector->display_info;
        unsigned int bp, hsync, vsync;
        u8 clk_delay;
        u32 val = 0;

        WARN_ON(!tcon->quirks->has_channel_0);

        //tcon->dclk_min_div = 6;
        tcon->dclk_min_div = 1;
        tcon->dclk_max_div = 127;
        sun4i_tcon0_mode_set_common(tcon, mode);

        /* Set dithering if needed */
        sun4i_tcon0_mode_set_dithering(tcon, connector);

        /* Adjust clock delay */
        clk_delay = sun4i_tcon_get_clk_delay(mode, 0);
        regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
                           SUN4I_TCON0_CTL_CLK_DELAY_MASK,

借我之前写的动态 修改uboot LCD 参数:V3s uboot 通过env 修改LCD 参数信息_kensey的博客-CSDN博客

如果一个产品已经打包封装,并且只有网口没有留下系统调试串口那么想要在linux 中修改uboot 下 env 信息就需要另外想办法了,好在uboot 已经把这部分功能考虑了;在uboot 根目录下 make env 即可得到可以操作的应用 fw_printenv;

root@ubuntu:/home/xxx/licheep_pro/u-boot-mmc# make CORSS=/opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- env
  HOSTCC  scripts/basic/fixdep
  LD      tools/env/built-in.o
  HOSTCC  tools/env/aes.o
  HOSTCC  tools/env/crc32.o
  HOSTCC  tools/env/ctype.o
  HOSTCC  tools/env/env_attr.o
  HOSTCC  tools/env/env_flags.o
  HOSTCC  tools/env/fw_env.o
  HOSTCC  tools/env/linux_string.o
  AR      tools/env/lib.a
  HOSTCC  tools/env/fw_env_main.o
  HOSTLD  tools/env/fw_printenv
  STRIP   tools/env/fw_printenv
root@ubuntu:/home/xxx/licheep_pro/u-boot-mmc#

如果是TF卡启动的话,将如下配置保存为 fw_env.config 写入/etc/ 下即可;

# Configuration file for fw_(printenv/setenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash.
# Futhermore, if the Flash sector size is omitted, this value is assumed to
# be the same as the Environment size, which is valid for NOR and SPI-dataflash
# Device offset must be prefixed with 0x to be parsed as a hexadecimal value.

# NOR example
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
#/dev/mtd1              0x0000          0x4000          0x4000
#/dev/mtd2              0x0000          0x4000          0x4000

# MTD SPI-dataflash example
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
#/dev/mtd5              0x4200          0x4200
#/dev/mtd6              0x4200          0x4200

# NAND example
#/dev/mtd0              0x4000          0x4000          0x20000                 2

# On a block device a negative offset is treated as a backwards offset from the
# end of the device/partition, rather than a forwards offset from the start.

# Block device example
/dev/mmcblk0            0x88000         0x20000
#/dev/mmcblk0           -0x20000        0x20000

# VFAT example
#/boot/uboot.env        0x0000          0x4000

如果想要动态修改LCD 参数 除去uboot 修改外,还需要修改 linux 启动所需要的设备数文件,

在内核 /arch/arm/boot/dts/sun8i-v3s-licheepi-zero-with-800x480-lcd.dts  ,找到相关LCD 配置文件,这里我的是 800*480 7寸液晶,

/*
 * Copyright (C) 2018 Icenowy Zheng 
 *
 * SPDX-License-Identifier: (GPL-2.0+ OR X11)
 */

 #include "sun8i-v3s-licheepi-zero-with-lcd.dtsi"

 &panel {
        compatible = "urt,umsh-8596md-t", "simple-panel";
};

具体的 compatible = "urt,umsh-8596md-t", "simple-panel"; 配置需要找到内核相关文件,改文件内部包含多种LCD 驱动参数可供使用;具体文件为:/drivers/gpu/drm/panel/panel-simple.c ,这里展示2563 行 一部分文件,该结构体内部有大量的屏幕信息,具体分辨率等信息查看 .data 对应的结构信息描述:

static const struct of_device_id platform_of_match[] = {
        {
                .compatible = "ampire,am-480272h3tmqw-t01h",
                .data = &ire_am_480272h3tmqw_t01h,
        }, {
                .compatible = "ampire,am800480r3tmqwa1h",
                .data = &ire_am800480r3tmqwa1h,
        }, {
                .compatible = "arm,rtsm-display",
                .data = &arm_rtsm,
        }, {
                .compatible = "auo,b101aw03",
                .data = &auo_b101aw03,
        }, {
                .compatible = "auo,b101ean01",
                .data = &auo_b101ean01,
        }, {
                .compatible = "auo,b101xtn01",
                .data = &auo_b101xtn01,
........

修改好交叉编译后,下载到ARM板 挂载 第一分区 , 使用fw_printenv 修改uboot 加载的设备数文件,重启完毕!

你可能感兴趣的:(arm开发)