Sarthak-Pandey opened a new pull request, #3867: URL: https://github.com/apache/nuttx-apps/pull/3867
*Note: Please adhere to Contributing Guidelines.* ## Summary This PR addresses and fixes [apache/nuttx-apps#2936](https://github.com/apache/nuttx-apps/issues/2936), where running `lvgldemo` on 32-bpp framebuffers (e.g. 1024x768 `FB_FMT_RGB32` on `/dev/fb0`) results in horizontally duplicated screen output, corrupted color channels, and a black bottom half. ### Root Causes 1. **Color depth & Stride mismatch:** When hardware expects 32-bpp (`FB_FMT_RGB32`), LVGL writing 16-bpp or writing without accounting for `pinfo.stride` (e.g., 4096 bytes vs 2048 bytes per scanline) causes half-width repetition and black lower-half rendering. 2. **Missing Alpha Channel (0xFF):** Framebuffer controllers displaying 32-bpp formats require the upper alpha byte (`0xff000000`) to be set; otherwise pixels are rendered transparent or discarded. 3. **Unaligned memory buffer access:** Display draw buffers must adhere to architecture cache line and DMA alignment requirements. ### Changes Made (Safeguard Architecture) - Added `lv_port_fbdev.c` and `lv_port_fbdev.h` providing an opt-in direct framebuffer driver via `CONFIG_EXAMPLES_LVGLDEMO_PORT_FBDEV`. - **Dynamic Format & Byte-Order Conversion:** Inspects `fb_videoinfo_t` and `fb_planeinfo_t` (format and bpp) and converts LVGL color structures into target hardware formats (RGB565, ARGB8888, RGBA8888, RGBX8888) with forced opaque alpha (`0xff000000u`). - **Stride & Offset Handling:** Uses `g_pinfo.stride`, `xoffset`, and `yoffset` to accurately calculate scanline destination memory addresses. - **Partial Draw Buffering:** Employs a 40-row partial draw buffer aligned with `LV_DRAW_BUF_ALIGN` (`aligned_data(LV_DRAW_BUF_ALIGN)`) to conserve memory (~160 KB) and prevent unaligned access faults on architectures like Cortex-M0/M3. - **Color Probe Diagnostic:** Added `CONFIG_EXAMPLES_LVGLDEMO_COLOR_PROBE` to write 3 test diagnostic pixels (Red, Green, Blue) at initialization to verify hardware byte order. ## Impact - **Users:** Fixes distorted and duplicated display on 32-bpp / 24-bpp framebuffers when running `lvgldemo` on NuttX. - **Compatibility:** Fully backward-compatible; `CONFIG_EXAMPLES_LVGLDEMO_PORT_FBDEV` defaults to `n`, preserving existing default behavior unless opted in. - **Build:** Configured for both GNU Make and CMake build systems. ## Testing - **Coding Standard:** Verified with `nxstyle` on all modified/new files. - **Code Review:** Passed CodeRabbit automated code review (`coderabbit review --agent --fresh`) with 0 findings. - **Host:** Windows 11 x86_64. - **Verification:** Verified buffer alignment rules (`LV_DRAW_BUF_ALIGN`), color conversion logic, and NuttX coding standards. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
