Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved emulation of ST7789 LCD controller #478

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

calc84maniac
Copy link
Contributor

@calc84maniac calc84maniac commented May 14, 2024

Implemented many features as documented in the Sitronix datasheet, as well as based on research of the actual behavior on real hardware.

New features:

  • MCU and VSYNC display modes, which scan the display using the LCD's internal clock
  • Porch control for RGB display mode, as well as porch and frame rate control for the new display modes
  • Approximate LCD response time emulation (exposed as a user setting)
  • Approximate analog gamma emulation (exposed as a user setting), as well as approximated presets
  • Configurable LCD internal clock rate in misc debug panel (between 9.5 MHz and 10.5 MHz)
  • Digital gamma emulation for red/blue components
  • Black/white color parameter for unused lines in partial mode
  • Endianness parameter for 16bpp pixel format through SPI
  • LCM Control parameter, as well as other parameters that reverse scan direction
  • RAM bypass and HV mode for RGB display mode

Fixed behavior:

  • Changes to certain display modes and scroll/partial parameters take effect only at the next VSYNC
  • VSYNC signal from the PL111 is properly ignored if the current frame hasn't finished yet
  • Various PL111 timing fixes, such as sending HSYNC signals during a multi-line VSYNC and properly applying the clock divisor in some places
  • Accurate timing for LCD RAM reads during display scanning
  • Low bits of color components are filled as configured for 12bpp and 16bpp pixel formats
  • Many LCD RAM pointer edge cases are fixed, and support is added for different wrapping modes
  • Fixed endianness handling for 16bpp modes on the PL111

Performance improvements:

  • Scheduler is rewritten to use 64-bit timestamps with a fixed (least common multiple) clock unit, and event clocks refactored to use multiplication
  • LCD scanning now batches pixels, and batches are only processed at the end of each line, before LCD RAM is modified on the current line, or when the inverted mode is changed
  • Partial and disabled display modes are checked and rendered only once per line, instead of on each pixel
  • Inverted and idle modes, as well as backlight level, are integrated into the gamma lookup and thus reduced to zero cost
  • Streamlined the hot path of DMA FIFO to RGB interface to LCD RAM, handling pixel format changes in parallel when possible
  • Non-DMA rendering mode also takes advantage of parallelized pixel format changes

@calc84maniac calc84maniac self-assigned this May 14, 2024
@adriweb adriweb force-pushed the feature/st7789 branch 5 times, most recently from 4184138 to 4323997 Compare May 14, 2024 07:21
@adriweb adriweb added the core label May 14, 2024
@calc84maniac calc84maniac force-pushed the feature/st7789 branch 2 times, most recently from a343a44 to 4727c75 Compare May 22, 2024 03:42
@calc84maniac calc84maniac marked this pull request as ready for review May 22, 2024 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants