TFT-LCD Driver Reference


1. Overview

This article is a reference for Spi interface TFT-LCD driver.


2. Spi Panel Driver Config

  1. Enable fbtft config in Kernel menuconfig, compile the marks in the figure into module.

  2. Add corresponding config in Dts

    Install with insomod after compilation.

    1. Remove the original fb module

      Remove insmod /config/modules/4.9.84/fbdev.ko in customer/demo.sh``insmod /config/modules/4.9.84/fbdev.ko and restart.(If there is zkgui, please also remove it)

    2. Load the fbtft module after restart

      insmod /config/modules/4.9.84/fbtft_device.ko busnum=1 name=admatec_b-berry28 cs=0 gpios="reset:21,dc:20" custom=1 speed=40000000 width=240 height=320 buswidth=8 mode=0 debug=7 dma=0
      

      name=admatec_b-berry28 should be the same as the name of fbtft_device_display displays[] in the driver.

      Note: spi timeout will be report if the speed parameter is too large, please reduce the value of speed.

    3. Load the corresponding TFT driver

      insmod /config/modules/fb\_st7796s.ko
      

      A node of dev/fb0 will be generated, and you can draw directly on fb.

  3. Modify according to the panel settings

    1. Panel initialization

      Fbtft-core.c

      fbtft_probe_common() -> fbtft_register_framebuffer() -> fbtftops.init_display()

      Use the initialization parameters of the following array to initialize the panel.

      Other settings are in fbtftops.set_var()/fbtftops.update_display()fbtftops.set_gamma().

    2. Refresh

      The upper layer refreshes fb through ioctl(g_fbFd, FBIOPAN_DISPLAY, &vinfo), corresponding to the bottom layer fbtft_update_display() -> fbtftops.write_vmem() -> fbtft_write_vmem16_bus8()- > fbtftops.write -> fbtft_write_spi()

      Note: spi sends data directly to the panel, but the data sent by RGB565 or RGB888 is not the same. The data sent by the upper layer to the driver must conform to the panel data format.

  4. ZKGUI needs to export ZK_GFX_ENABLE=0, please disable gfx