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:

SDL_RenderCopy(renderer,imagetex,NULL,NULL);
SDL_SetRenderDrawColor(renderer,0,0,255,255);
SDL_RenderFillRect(renderer,&rect);
SDL_RenderPresent(renderer);

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.