raspberry: expose second display.

This lets apps see and choose between both an HDMI and DSI-connected display,
such as a television and the Pi Foundation's official touchscreen. It only
exposes the second display if the hardware reports that it is connected.
This commit is contained in:
Ryan C. Gordon 2019-02-19 23:46:54 -05:00
parent 90a075d75f
commit 6fbe9e23fa

View File

@ -154,28 +154,34 @@ VideoBootStrap RPI_bootstrap = {
RPI_Create
};
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
int
RPI_VideoInit(_THIS)
static void
AddDispManXDisplay(const int display_id)
{
DISPMANX_MODEINFO_T modeinfo;
DISPMANX_DISPLAY_HANDLE_T handle;
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData *data;
uint32_t w,h;
/* Initialize BCM Host */
bcm_host_init();
SDL_zero(current_mode);
if (graphics_get_display_size( 0, &w, &h) < 0) {
return -1;
handle = vc_dispmanx_display_open(display_id);
if (!handle) {
return; /* this display isn't available */
}
current_mode.w = w;
current_mode.h = h;
if (vc_dispmanx_display_get_info(handle, &modeinfo) < 0) {
vc_dispmanx_display_close(handle);
return;
}
/* RPI_GetRefreshRate() doesn't distinguish between displays. I'm not sure the hardware distinguishes either */
SDL_zero(current_mode);
current_mode.w = modeinfo.width;
current_mode.h = modeinfo.height;
current_mode.refresh_rate = RPI_GetRefreshRate();
/* 32 bpp for default */
current_mode.format = SDL_PIXELFORMAT_ABGR8888;
@ -189,14 +195,25 @@ RPI_VideoInit(_THIS)
/* Allocate display internal data */
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
if (data == NULL) {
return SDL_OutOfMemory();
vc_dispmanx_display_close(handle);
return; /* oh well */
}
data->dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
data->dispman_display = handle;
display.driverdata = data;
SDL_AddVideoDisplay(&display);
}
int
RPI_VideoInit(_THIS)
{
/* Initialize BCM Host */
bcm_host_init();
AddDispManXDisplay(DISPMANX_ID_MAIN_LCD); /* your default display */
AddDispManXDisplay(DISPMANX_ID_FORCE_OTHER); /* an "other" display...maybe DSI-connected screen while HDMI is your main */
#ifdef SDL_INPUT_LINUXEV
if (SDL_EVDEV_Init() < 0) {