KMSDRM: Add gamma support

main
Cacodemon345 2021-02-25 15:21:59 +06:00 committed by Sam Lantinga
parent 72f7a10cef
commit d2d834b990
3 changed files with 36 additions and 0 deletions

View File

@ -59,6 +59,10 @@ SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId))
SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId, SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId,
uint32_t x, uint32_t y, uint32_t *connectors, int count, uint32_t x, uint32_t y, uint32_t *connectors, int count,
drmModeModeInfoPtr mode)) drmModeModeInfoPtr mode))
SDL_KMSDRM_SYM(int,drmModeCrtcGetGamma,(int fd, uint32_t crtc_id, uint32_t size,
uint16_t *red, uint16_t *green, uint16_t *blue))
SDL_KMSDRM_SYM(int,drmModeCrtcSetGamma,(int fd, uint32_t crtc_id, uint32_t size,
uint16_t *red, uint16_t *green, uint16_t *blue))
SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle, SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle,
uint32_t width, uint32_t height)) uint32_t width, uint32_t height))
SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle, SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle,

View File

@ -243,6 +243,8 @@ KMSDRM_CreateDevice(int devindex)
device->SetWindowPosition = KMSDRM_SetWindowPosition; device->SetWindowPosition = KMSDRM_SetWindowPosition;
device->SetWindowSize = KMSDRM_SetWindowSize; device->SetWindowSize = KMSDRM_SetWindowSize;
device->SetWindowFullscreen = KMSDRM_SetWindowFullscreen; device->SetWindowFullscreen = KMSDRM_SetWindowFullscreen;
device->GetWindowGammaRamp = KMSDRM_GetWindowGammaRamp;
device->SetWindowGammaRamp = KMSDRM_SetWindowGammaRamp;
device->ShowWindow = KMSDRM_ShowWindow; device->ShowWindow = KMSDRM_ShowWindow;
device->HideWindow = KMSDRM_HideWindow; device->HideWindow = KMSDRM_HideWindow;
device->RaiseWindow = KMSDRM_RaiseWindow; device->RaiseWindow = KMSDRM_RaiseWindow;
@ -1348,6 +1350,34 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
windata->surface_w, windata->surface_h); windata->surface_w, windata->surface_h);
} }
int
KMSDRM_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{
SDL_WindowData *windata = (SDL_WindowData*)window->driverdata;
SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata;
SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window);
SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata;
if (KMSDRM_drmModeCrtcGetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &ramp[0*256], &ramp[1*256], &ramp[2*256]) == -1)
{
return SDL_SetError("Failed to get gamma ramp");
}
return 0;
}
int
KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
{
SDL_WindowData *windata = (SDL_WindowData*)window->driverdata;
SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata;
SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window);
SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata;
if (KMSDRM_drmModeCrtcSetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &ramp[0*256], &ramp[1*256], &ramp[2*256]) == -1)
{
return SDL_SetError("Failed to set gamma ramp");
}
return 0;
}
int int
KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{ {

View File

@ -133,6 +133,8 @@ void KMSDRM_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window); void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window);
void KMSDRM_SetWindowSize(_THIS, SDL_Window * window); void KMSDRM_SetWindowSize(_THIS, SDL_Window * window);
void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen); void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen);
int KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
int KMSDRM_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
void KMSDRM_ShowWindow(_THIS, SDL_Window * window); void KMSDRM_ShowWindow(_THIS, SDL_Window * window);
void KMSDRM_HideWindow(_THIS, SDL_Window * window); void KMSDRM_HideWindow(_THIS, SDL_Window * window);
void KMSDRM_RaiseWindow(_THIS, SDL_Window * window); void KMSDRM_RaiseWindow(_THIS, SDL_Window * window);