RetroArch/gfx/common/drm_common.h

78 lines
1.7 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
2016-01-10 03:41:52 +00:00
* Copyright (c) 2011-2016 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DRM_COMMON_H
#define __DRM_COMMON_H
#include <stdint.h>
#include <stddef.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <poll.h>
2015-11-26 17:23:51 +00:00
#include <boolean.h>
2016-06-03 06:06:49 +00:00
#include <retro_common_api.h>
2015-11-28 16:16:19 +00:00
#include <retro_inline.h>
2015-11-26 17:23:51 +00:00
2016-06-03 06:06:49 +00:00
RETRO_BEGIN_DECLS
extern uint32_t g_connector_id;
extern int g_drm_fd;
2015-11-26 16:30:01 +00:00
extern uint32_t g_crtc_id;
2015-11-27 23:33:01 +00:00
extern struct pollfd g_drm_fds;
2015-11-26 16:30:01 +00:00
extern drmModeConnector *g_drm_connector;
extern drmModeModeInfo *g_drm_mode;
extern drmEventContext g_drm_evctx;
2015-11-26 17:23:51 +00:00
bool drm_get_encoder(int fd);
/* Restore the original CRTC. */
void drm_restore_crtc(void);
2015-11-26 17:47:07 +00:00
bool drm_get_resources(int fd);
bool drm_get_connector(int id);
void drm_setup(int fd);
2015-11-26 16:34:35 +00:00
void drm_free(void);
2015-11-28 16:16:19 +00:00
static INLINE bool drm_wait_flip(int timeout)
{
g_drm_fds.revents = 0;
if (poll(&g_drm_fds, 1, timeout) < 0)
return false;
if (g_drm_fds.revents & (POLLHUP | POLLERR))
return false;
if (g_drm_fds.revents & POLLIN)
{
drmHandleEvent(g_drm_fd, &g_drm_evctx);
return true;
}
return false;
}
2016-06-03 06:06:49 +00:00
RETRO_END_DECLS
#endif