This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3354: Incorrect Color Output From SGX

Part Number: AM3354

We are running Qt with EGLFS on a custom PCB with the AM3354 processor, and we are seeing gray "#808080" displaying as a yellowish gray rather than a gray where they would all be equivalent.

Here is the output of the gfx_check.sh:

root@ercss5:~# /etc/init.d/gfx_check.sh 
WSEGL settings
WindowSystem=libpvrGBMWSEGL.so
DefaultPixelFormat=RGB565
------
ARM CPU information
processor	: 0
model name	: ARMv7 Processor rev 2 (v7l)
BogoMIPS	: 597.60
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpd32 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x3
CPU part	: 0xc08
CPU revision	: 2

Hardware	: Generic AM33XX (Flattened Device Tree)
Revision	: 0000
Serial		: 34:03:de:73:c0:51
------
SGX driver information
Version SGX_DDK_Linux_XOrg sgxddk 1.17@4948957 (release) omap_linux
System Version String: SGX revision = 125
------
Framebuffer settings

mode "320x480"
    geometry 320 480 320 480 16
    timings 0 0 0 0 0 0 0
    accel true
    rgba 5/11,6/5,5/0,0/0
endmode

Frame buffer device information:
    Name        : DRM emulated
    Address     : (nil)
    Size        : 307200
    Type        : PACKED PIXELS
    Visual      : TRUECOLOR
    XPanStep    : 1
    YPanStep    : 1
    YWrapStep   : 0
    LineLength  : 640
    Accelerator : No
------
Rotation settings
0
------
Kernel Module information
Module                  Size  Used by
pvrsrvkm              397312  0
musb_dsps              20480  0
musb_hdrc              73728  1 musb_dsps
pm33xx                 16384  0
wkup_m3_ipc            16384  1 pm33xx
wkup_m3_rproc          16384  1
remoteproc             45056  2 wkup_m3_rproc,wkup_m3_ipc
omap_aes_driver        24576  0
crypto_engine          16384  1 omap_aes_driver
omap_sham              28672  0
omap_crypto            16384  1 omap_aes_driver
ti_emif_sram           16384  1 pm33xx
goodix                 20480  0
rtc_omap               20480  2
musb_am335x            16384  0
omap_wdt               16384  0
sch_fq_codel           20480  1
------
Boot settings
console=ttyO0,115200n8 root=PARTUUID=53edaf4f-02 rw rootfstype=ext4 rootwait
------
Linux Kernel version
Linux ercss5 4.19.38-g4dae378bbe #1 PREEMPT Tue Sep 1 21:12:19 UTC 2020 armv7l GNU/Linux

Here is the qt_env.sh:

root@ercss5:~# cat /etc/profile.d/qt_env.sh 
#!/bin/sh

### QT Environment Variables ###
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS="rotate=180"
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
export QT_QPA_EGLFS_KMS_CONFIG=/etc/qt5/eglfs_kms_cfg.json
export QT_QPA_EGLFS_INTEGRATION=none
export QT_QPA_EGLFS_DEBUG=1
export QSG_INFO=1
export QT_LOGGING_RULES=qt.qpa.*=true

Here is the output when running the application:

root@ercss5:~# gui
qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_emu", "eglfs_kms")
qt.qpa.egldeviceintegration: Using base device integration
[  433.918927] ST7796S get_mode: 72
qt.qpa.input: libinput: event0  - Goodix Capacitive TouchScreen: is tagged by udev as: Keyboard Touchscreen
qt.qpa.input: libinput: event0  - Goodix Capacitive TouchScreen: device is a keyboard
qt.qpa.input: libinput: event0  - Goodix Capacitive TouchScreen: device is a touch device
qt.qpa.input: Using xkbcommon for key mapping
qt.scenegraph.general: threaded render loop
qt.scenegraph.general: Using sg animation driver
qt.scenegraph.general: Animation Driver: using vsync: 16.67 ms
Created context for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, colorSpace QSurfaceFormat::ColorSpace(DefaultColorSpace), profile  QSurfaceFormat::OpenGLContextProfile(NoProfile)) with config:
	EGL_BUFFER_SIZE: 16
	EGL_ALPHA_SIZE: 0
	EGL_BLUE_SIZE: 5
	EGL_GREEN_SIZE: 6
	EGL_RED_SIZE: 5
	EGL_DEPTH_SIZE: 24
	EGL_STENCIL_SIZE: 8
	EGL_CONFIG_CAVEAT: 12344
	EGL_CONFIG_ID: 11
	EGL_LEVEL: 0
	EGL_MAX_PBUFFER_HEIGHT: 2048
	EGL_MAX_PBUFFER_PIXELS: 4194304
	EGL_MAX_PBUFFER_WIDTH: 2048
	EGL_NATIVE_RENDERABLE: 0
	EGL_NATIVE_VISUAL_ID: 0
	EGL_NATIVE_VISUAL_TYPE: 0
	EGL_SAMPLES: 0
	EGL_SAMPLE_BUFFERS: 0
	EGL_SURFACE_TYPE: 1541
	EGL_TRANSPARENT_TYPE: 12344
	EGL_TRANSPARENT_BLUE_VALUE: 0
	EGL_TRANSPARENT_GREEN_VALUE: 0
	EGL_TRANSPARENT_RED_VALUE: 0
	EGL_BIND_TO_TEXTURE_RGB: 0
	EGL_BIND_TO_TEXTURE_RGBA: 0
	EGL_MIN_SWAP_INTERVAL: 1
	EGL_MAX_SWAP_INTERVAL: 10
qt.scenegraph.general: Using sg animation driver
qt.scenegraph.general: Animation Driver: using vsync: 16.67 ms
qt.scenegraph.general: texture atlas dimensions: 512x512
qt.scenegraph.general: R/G/B/A Buffers:   5 6 5 0
qt.scenegraph.general: Depth Buffer:      24
qt.scenegraph.general: Stencil Buffer:    8
qt.scenegraph.general: Samples:           0
qt.scenegraph.general: GL_VENDOR:         Imagination Technologies
qt.scenegraph.general: GL_RENDERER:       PowerVR SGX 530
qt.scenegraph.general: GL_VERSION:        OpenGL ES 2.0 build 1.17@4948957
qt.scenegraph.general: GL_EXTENSIONS:     GL_OES_EGL_image_external GL_OES_vertex_array_object GL_EXT_discard_framebuffer GL_OES_required_internalformat GL_IMG_read_format GL_OES_fbo_render_mipmap GL_OES_packed_depth_stencil GL_OES_compressed_ETC1_RGB8_texture GL_OES_mapbuffer GL_OES_surfaceless_context GL_EXT_texture_rg GL_OES_EGL_image GL_OES_get_program_binary GL_IMG_texture_format_BGRA8888 GL_IMG_multisampled_render_to_texture GL_OES_element_index_uint GL_OES_egl_sync GL_EXT_multisampled_render_to_texture GL_EXT_texture_storage GL_IMG_shader_binary GL_OES_fragment_precision_high GL_OES_vertex_half_float GL_KHR_debug GL_IMG_texture_compression_pvrtc GL_IMG_texture_npot GL_EXT_texture_format_BGRA8888 GL_OES_texture_float GL_OES_texture_half_float GL_OES_rgb8_rgba8 GL_EXT_multi_draw_arrays GL_OES_depth24 GL_IMG_uniform_buffer_object GL_IMG_program_binary GL_EXT_shader_texture_lod GL_OES_depth_texture GL_OES_standard_derivatives GL_EXT_blend_minmax
qt.scenegraph.general: Max Texture Size: 2048
qt.scenegraph.general: Debug context:    false

The display we are using accepts an 18-bit and 16-bit data bus, and we are outputting a 16-bit data bus from the AM3354 into the 18-bit data bus on the display. The MSB and LSB for red and green are tied together. However, to ensure this is not the issue we tied all three LSB bits to ground to give an RGB555 data bus instead. This did not correct the issue and the results are identical. This is the current state of our test board, but we have another that has an intact RGB565 data bus.

What leads me to suspect that the SGX is causing the issue is that I created a test application that displays various grays "#808080", "#848484" and variations between. I ran this with the EGLFS platform and see the yellow color when displaying "#808080" but see a proper gray when displaying "#848484". The variations of "#808080" and "#848484" all appear differently, but this should not be possible with an RGB555 data bus. Then, I ran the application with the LinuxFB platform and every variation of gray were identical, because when output to the RGB555 bus they can only be output as "#808080". So this is leading me to believe that the SGX is manipulating these colors unfavorably, but I am unable to determine the configuration to correct this.

Here is an image to display the discoloring:

And here is an image displaying a proper gray:

I have images of the variations as well, and if they are necessary will post them to this thread.

Thank you for your assistance with this issue,

Jake