mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
kmsdrm: Always use spaces for indentation. Always use SDL_calloc() for calloc.
This commit is contained in:
parent
cfc1362011
commit
87a86675ed
@ -117,7 +117,9 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||||
SDL_assert(surface->pitch == surface->w * 4);
|
SDL_assert(surface->pitch == surface->w * 4);
|
||||||
|
|
||||||
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
|
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, GBM_FORMAT_ARGB8888,
|
||||||
|
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
||||||
|
{
|
||||||
SDL_SetError("Unsupported pixel format for cursor");
|
SDL_SetError("Unsupported pixel format for cursor");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -136,7 +138,8 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||||||
|
|
||||||
/* Find out what GBM cursor size is recommended by the driver. */
|
/* Find out what GBM cursor size is recommended by the driver. */
|
||||||
if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) ||
|
if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) ||
|
||||||
KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h)) {
|
KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h))
|
||||||
|
{
|
||||||
SDL_SetError("Could not get the recommended GBM cursor size");
|
SDL_SetError("Could not get the recommended GBM cursor size");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -152,8 +155,8 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||||||
curdata->w = usable_cursor_w;
|
curdata->w = usable_cursor_w;
|
||||||
curdata->h = usable_cursor_h;
|
curdata->h = usable_cursor_h;
|
||||||
|
|
||||||
curdata->bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, usable_cursor_w, usable_cursor_h, GBM_FORMAT_ARGB8888,
|
curdata->bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, usable_cursor_w, usable_cursor_h,
|
||||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||||
|
|
||||||
if (!curdata->bo) {
|
if (!curdata->bo) {
|
||||||
SDL_SetError("Could not create GBM cursor BO");
|
SDL_SetError("Could not create GBM cursor BO");
|
||||||
@ -372,11 +375,9 @@ KMSDRM_WarpMouseGlobal(int x, int y)
|
|||||||
/* And now update the cursor graphic position on screen. */
|
/* And now update the cursor graphic position on screen. */
|
||||||
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
|
curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata;
|
||||||
if (curdata->bo) {
|
if (curdata->bo) {
|
||||||
|
|
||||||
if (drm_atomic_movecursor(curdata, x, y)) {
|
if (drm_atomic_movecursor(curdata, x, y)) {
|
||||||
return SDL_SetError("drm_atomic_movecursor() failed.");
|
return SDL_SetError("drm_atomic_movecursor() failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return SDL_SetError("Cursor not initialized properly.");
|
return SDL_SetError("Cursor not initialized properly.");
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,9 @@ static EGLSyncKHR create_fence(int fd, _THIS)
|
|||||||
EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
|
EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR(_this->egl_data->egl_display,
|
EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR
|
||||||
EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
|
(_this->egl_data->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
|
||||||
|
|
||||||
assert(fence);
|
assert(fence);
|
||||||
return fence;
|
return fence;
|
||||||
}
|
}
|
||||||
@ -132,6 +133,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
|||||||
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||||
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
/* EXPORT the GPU-side FENCE OBJECT to the fence INPUT FD, so we */
|
/* EXPORT the GPU-side FENCE OBJECT to the fence INPUT FD, so we */
|
||||||
/* can pass it into the kernel. Atomic ioctl will pass the */
|
/* can pass it into the kernel. Atomic ioctl will pass the */
|
||||||
@ -144,8 +146,8 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
|||||||
/* in the CMDSTREAM to be lifted when the CMDSTREAM to this point */
|
/* in the CMDSTREAM to be lifted when the CMDSTREAM to this point */
|
||||||
/* is completed). */
|
/* is completed). */
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID
|
dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID (_this->egl_data->egl_display,
|
||||||
(_this->egl_data->egl_display, dispdata->gpu_fence);
|
dispdata->gpu_fence);
|
||||||
|
|
||||||
_this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->gpu_fence);
|
_this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->gpu_fence);
|
||||||
assert(dispdata->kms_in_fence_fd != -1);
|
assert(dispdata->kms_in_fence_fd != -1);
|
||||||
@ -205,8 +207,9 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
|||||||
/* Do we have a pending modesetting? If so, set the necessary
|
/* Do we have a pending modesetting? If so, set the necessary
|
||||||
props so it's included in the incoming atomic commit. */
|
props so it's included in the incoming atomic commit. */
|
||||||
if (dispdata->modeset_pending) {
|
if (dispdata->modeset_pending) {
|
||||||
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
|
||||||
uint32_t blob_id;
|
uint32_t blob_id;
|
||||||
|
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
|
||||||
|
|
||||||
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||||
add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
|
add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
|
||||||
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
|
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
|
||||||
@ -352,7 +355,8 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
|||||||
if (windata->swap_window == NULL) {
|
if (windata->swap_window == NULL) {
|
||||||
/* We want the fenced version by default, but it needs extensions. */
|
/* We want the fenced version by default, but it needs extensions. */
|
||||||
if ( (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) ||
|
if ( (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) ||
|
||||||
(!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) ) {
|
(!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) )
|
||||||
|
{
|
||||||
windata->swap_window = KMSDRM_GLES_SwapWindowDoubleBuffered;
|
windata->swap_window = KMSDRM_GLES_SwapWindowDoubleBuffered;
|
||||||
} else {
|
} else {
|
||||||
windata->swap_window = KMSDRM_GLES_SwapWindowFenced;
|
windata->swap_window = KMSDRM_GLES_SwapWindowFenced;
|
||||||
|
@ -157,11 +157,16 @@ static dumb_buffer *KMSDRM_CreateDumbBuffer(_THIS)
|
|||||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
|
||||||
dumb_buffer *ret = calloc(1, sizeof(*ret));
|
|
||||||
struct drm_mode_create_dumb create;
|
struct drm_mode_create_dumb create;
|
||||||
struct drm_mode_map_dumb map;
|
struct drm_mode_map_dumb map;
|
||||||
struct drm_mode_destroy_dumb destroy;
|
struct drm_mode_destroy_dumb destroy;
|
||||||
|
|
||||||
|
dumb_buffer *ret = SDL_calloc(1, sizeof(*ret));
|
||||||
|
if (!ret)
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The create ioctl uses the combination of depth and bpp to infer
|
* The create ioctl uses the combination of depth and bpp to infer
|
||||||
* a format; 24/32 refers to DRM_FORMAT_XRGB8888 as defined in
|
* a format; 24/32 refers to DRM_FORMAT_XRGB8888 as defined in
|
||||||
@ -499,8 +504,8 @@ static int get_plane_id(_THIS, uint32_t plane_type)
|
|||||||
/* See if the current CRTC is available for this plane. */
|
/* See if the current CRTC is available for this plane. */
|
||||||
if (plane->possible_crtcs & (1 << crtc_index)) {
|
if (plane->possible_crtcs & (1 << crtc_index)) {
|
||||||
|
|
||||||
drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
|
drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(
|
||||||
plane_id, DRM_MODE_OBJECT_PLANE);
|
viddata->drm_fd, plane_id, DRM_MODE_OBJECT_PLANE);
|
||||||
ret = plane_id;
|
ret = plane_id;
|
||||||
|
|
||||||
/* Iterate on the plane props to find the type of the plane,
|
/* Iterate on the plane props to find the type of the plane,
|
||||||
@ -510,8 +515,7 @@ static int get_plane_id(_THIS, uint32_t plane_type)
|
|||||||
drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
||||||
props->props[j]);
|
props->props[j]);
|
||||||
|
|
||||||
if ((strcmp(p->name, "type") == 0) &&
|
if ((strcmp(p->name, "type") == 0) && (props->prop_values[j] == plane_type)) {
|
||||||
(props->prop_values[j] == plane_type)) {
|
|
||||||
/* found our plane, use that: */
|
/* found our plane, use that: */
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
@ -1133,9 +1137,9 @@ KMSDRM_VideoInit(_THIS)
|
|||||||
SDL_VideoDisplay display = {0};
|
SDL_VideoDisplay display = {0};
|
||||||
|
|
||||||
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
||||||
dispdata->display_plane = calloc(1, sizeof(*dispdata->display_plane));
|
dispdata->display_plane = SDL_calloc(1, sizeof(*dispdata->display_plane));
|
||||||
dispdata->crtc = calloc(1, sizeof(*dispdata->crtc));
|
dispdata->crtc = SDL_calloc(1, sizeof(*dispdata->crtc));
|
||||||
dispdata->connector = calloc(1, sizeof(*dispdata->connector));
|
dispdata->connector = SDL_calloc(1, sizeof(*dispdata->connector));
|
||||||
|
|
||||||
dispdata->atomic_flags = 0;
|
dispdata->atomic_flags = 0;
|
||||||
dispdata->atomic_req = NULL;
|
dispdata->atomic_req = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user