* Add retro_get_fd to retro_file.c

* Use retro_file in gfx/drivers_context/drm_egl_ctx.c
This commit is contained in:
twinaphex 2015-09-18 03:47:44 +02:00
parent a547fdef50
commit 133e85298f
3 changed files with 20 additions and 4 deletions

View File

@ -21,7 +21,6 @@
#include <stdint.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
@ -40,6 +39,7 @@
#include <gbm.h>
#include <file/dir_list.h>
#include <retro_file.h>
#include "../../driver.h"
#include "../../runloop.h"
@ -57,6 +57,7 @@
typedef struct gfx_ctx_drm_egl_data
{
bool g_use_hw_ctx;
RFILE *g_drm;
int g_drm_fd;
uint32_t g_crtc_id;
uint32_t g_connector_id;
@ -356,7 +357,7 @@ static void free_drm_resources(gfx_ctx_drm_egl_data_t *drm)
drmModeFreeCrtc(drm->g_orig_crtc);
if (drm->g_drm_fd >= 0)
close(drm->g_drm_fd);
retro_fclose(drm->g_drm);
drm->g_gbm_surface = NULL;
drm->g_gbm_dev = NULL;
@ -457,13 +458,15 @@ nextgpu:
}
gpu = gpu_descriptors->elems[gpu_index++].data;
drm->g_drm_fd = open(gpu, O_RDWR);
if (drm->g_drm_fd < 0)
drm->g_drm = retro_fopen(gpu, RFILE_MODE_READ_WRITE, -1);
if (!drm->g_drm)
{
RARCH_WARN("[KMS/EGL]: Couldn't open DRM device.\n");
goto nextgpu;
}
drm->g_drm_fd = retro_get_fd(drm->g_drm);
drm->g_resources = drmModeGetResources(drm->g_drm_fd);
if (!drm->g_resources)
{

View File

@ -53,6 +53,17 @@ struct RFILE
#endif
};
int retro_get_fd(RFILE *stream)
{
if (!stream)
return -1;
#if defined(HAVE_BUFFERED_IO)
return fileno(stream->fd);
#else
return stream->fd;
#endif
}
RFILE *retro_fopen(const char *path, unsigned mode, ssize_t len)
{
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));

View File

@ -55,6 +55,8 @@ void retro_fclose(RFILE *stream);
bool retro_fmemcpy(const char *path, char *s, size_t len, ssize_t *bytes_written);
int retro_get_fd(RFILE *stream);
#ifdef __cplusplus
}
#endif