drm_get_connector - cleanup

This commit is contained in:
twinaphex 2020-03-06 23:18:22 +01:00
parent 304cd05dc6
commit 250468a1ba
3 changed files with 11 additions and 6 deletions

View File

@ -64,11 +64,11 @@ bool drm_get_resources(int fd)
return true;
}
bool drm_get_connector(int fd, video_frame_info_t *video_info)
bool drm_get_connector(int fd, unsigned monitor_index)
{
unsigned i;
unsigned monitor_index = 0;
unsigned monitor = MAX(video_info->monitor_index, 1);
unsigned monitor = MAX(monitor_index, 1);
/* Enumerate all connectors. */

View File

@ -54,7 +54,7 @@ void drm_setup(int fd);
void drm_free(void);
bool drm_get_connector(int fd, video_frame_info_t *video_info);
bool drm_get_connector(int fd, unsigned monitor_index);
float drm_get_refresh_rate(void *data);

View File

@ -398,8 +398,10 @@ static void *gfx_ctx_drm_init(video_frame_info_t *video_info, void *video_driver
const char *gpu = NULL;
struct string_list *gpu_descriptors = NULL;
#endif
settings_t *settings = config_get_ptr();
gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)
calloc(1, sizeof(gfx_ctx_drm_data_t));
unsigned video_monitor_index = settings->uints.video_monitor_index;
if (!drm)
return NULL;
@ -431,7 +433,7 @@ nextgpu:
if (!drm_get_resources(fd))
goto nextgpu;
if (!drm_get_connector(fd, video_info))
if (!drm_get_connector(fd, video_monitor_index))
goto nextgpu;
if (!drm_get_encoder(fd))
@ -442,10 +444,13 @@ nextgpu:
/* Choose the optimal video mode for get_video_size():
- the current video mode from the CRTC
- otherwise pick first connector mode */
if (g_orig_crtc->mode_valid) {
if (g_orig_crtc->mode_valid)
{
drm->fb_width = g_orig_crtc->mode.hdisplay;
drm->fb_height = g_orig_crtc->mode.vdisplay;
} else {
}
else
{
drm->fb_width = g_drm_connector->modes[0].hdisplay;
drm->fb_height = g_drm_connector->modes[0].vdisplay;
}