kmsdrm: added missing checks

This commit is contained in:
antonino 2022-08-22 17:49:49 +02:00 committed by Sam Lantinga
parent c1e0873940
commit 605b50fcd9
1 changed files with 10 additions and 6 deletions

View File

@ -557,24 +557,23 @@ KMSDRM_CrtcGetPropId(uint32_t drm_fd,
return prop_id; return prop_id;
} }
static uint32_t KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id) { static bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) {
drmModeObjectPropertiesPtr drm_props; drmModeObjectPropertiesPtr drm_props;
uint32_t vrr_prop_id;
drm_props = KMSDRM_drmModeObjectGetProperties(drm_fd, drm_props = KMSDRM_drmModeObjectGetProperties(drm_fd,
crtc_id, crtc_id,
DRM_MODE_OBJECT_CRTC); DRM_MODE_OBJECT_CRTC);
if (!drm_props) if (!drm_props)
exit(-1); return false;
vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd, *vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd,
drm_props, drm_props,
"VRR_ENABLED"); "VRR_ENABLED");
KMSDRM_drmModeFreeObjectProperties(drm_props); KMSDRM_drmModeFreeObjectProperties(drm_props);
return vrr_prop_id; return true;
} }
static SDL_bool static SDL_bool
@ -591,6 +590,9 @@ KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd,
output_id, output_id,
DRM_MODE_OBJECT_CONNECTOR); DRM_MODE_OBJECT_CONNECTOR);
if(!props)
return SDL_FALSE;
for (i = 0; !found && i < props->count_props; ++i) { for (i = 0; !found && i < props->count_props; ++i) {
drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]);
@ -613,7 +615,9 @@ KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd,
void void
KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled) KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, SDL_bool enabled)
{ {
uint32_t vrr_prop_id = KMSDRM_VrrPropId(drm_fd, crtc_id); uint32_t vrr_prop_id;
if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id))
return;
KMSDRM_drmModeObjectSetProperty(drm_fd, KMSDRM_drmModeObjectSetProperty(drm_fd,
crtc_id, crtc_id,