SDL2 Linux framebuffer color conversion

I’m working on an reimplementation of the Linux framebuffer support for
SDL2. The process looks promising so far but there is a problem or
misunderstanding in the color mapping. My display pixel format is BGR24
(calculated with SDL_MasksToPixelFormatEnum), so my display format is
calculated correct. I checked the masks myself and they are also
correct. 24 bit rgb image rendering works, jpeg image rendering works
also correct.

The following excerpt shows the video device creation. The pixel format
seems to be registered correct.

SDL_DisplayMode displaymode;
SDL_VideoDisplay display;
int status;
displaymode.format = pixelformat; //is BGR24 (my system is little endian)
display.current_mode = displaymode;
display.desktop_mode = displaymode;
status = SDL_AddVideoDisplay(&display);

The problem is the manual color setting with:


The rectangle should be blue but it is red. Rendering a green rectangle
works so red and blue channel have wrong masks. I don’t understand where
the pixel conversion in SDL2 happens or if it happens somewhere.