Create drm_get_encoder

This commit is contained in:
twinaphex 2015-11-26 18:23:51 +01:00
parent 0225e2e65a
commit 60ead8f6b1
4 changed files with 35 additions and 30 deletions

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../verbosity.h"
#include "drm_common.h"
uint32_t g_connector_id;
@ -46,6 +48,33 @@ void drm_restore_crtc(void)
g_orig_crtc = NULL;
}
bool drm_get_encoder(int fd)
{
unsigned i;
for (i = 0; i < g_drm_resources->count_encoders; i++)
{
g_drm_encoder = drmModeGetEncoder(fd, g_drm_resources->encoders[i]);
if (!g_drm_encoder)
continue;
if (g_drm_encoder->encoder_id == g_drm_connector->encoder_id)
break;
drmModeFreeEncoder(g_drm_encoder);
g_drm_encoder = NULL;
}
if (!g_drm_encoder)
{
RARCH_WARN("[DRM]: Couldn't find DRM encoder.\n");
return false;
}
return true;
}
void drm_free(void)
{
if (g_drm_encoder)

View File

@ -23,6 +23,8 @@
#include <xf86drmMode.h>
#include <poll.h>
#include <boolean.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -41,6 +43,8 @@ extern drmModeModeInfo *g_drm_mode;
extern drmEventContext g_drm_evctx;
bool drm_get_encoder(int fd);
/* Restore the original CRTC. */
void drm_restore_crtc(void);

View File

@ -595,19 +595,7 @@ static int exynos_open(struct exynos_data *pdata)
goto fail;
}
for (i = 0; i < g_drm_resources->count_encoders; i++)
{
g_drm_encoder = drmModeGetEncoder(fd, g_drm_resources->encoders[i]);
if (!g_drm_encoder)
continue;
if (g_drm_encoder->encoder_id == g_drm_connector->encoder_id)
break;
drmModeFreeEncoder(g_drm_encoder);
g_drm_encoder = NULL;
}
drm_get_encoder(fd);
/* Setup the flip handler. */
g_drm_fds.fd = fd;

View File

@ -426,24 +426,8 @@ nextgpu:
goto nextgpu;
}
for (i = 0; i < g_drm_resources->count_encoders; i++)
{
g_drm_encoder = drmModeGetEncoder(fd, g_drm_resources->encoders[i]);
if (!g_drm_encoder)
continue;
if (g_drm_encoder->encoder_id == g_drm_connector->encoder_id)
break;
drmModeFreeEncoder(g_drm_encoder);
g_drm_encoder = NULL;
}
if (!g_drm_encoder)
{
RARCH_WARN("[KMS/EGL]: Couldn't find DRM encoder.\n");
if (!drm_get_encoder(fd))
goto nextgpu;
}
for (i = 0; i < g_drm_connector->count_modes; i++)
{