*/
/*
- * TODO the types we are after are defined in diffrent headers on diffrent
+ * TODO the types we are after are defined in different headers on different
* platforms find which headers to include to get uint32_t
*/
{
struct drm_mode_get_connector conn, counts;
drmModeConnectorPtr r = NULL;
+ struct drm_mode_modeinfo stack_mode;
memclear(conn);
conn.connector_id = connector_id;
if (!probe) {
conn.count_modes = 1;
- conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo)));
+ conn.modes_ptr = VOID2U64(&stack_mode);
}
if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
goto err_allocs;
} else {
conn.count_modes = 1;
- conn.modes_ptr = VOID2U64(drmMalloc(sizeof(struct drm_mode_modeinfo)));
+ conn.modes_ptr = VOID2U64(&stack_mode);
}
if (conn.count_encoders) {
counts.count_encoders < conn.count_encoders) {
drmFree(U642VOID(conn.props_ptr));
drmFree(U642VOID(conn.prop_values_ptr));
- drmFree(U642VOID(conn.modes_ptr));
+ if (U642VOID(conn.modes_ptr) != &stack_mode)
+ drmFree(U642VOID(conn.modes_ptr));
drmFree(U642VOID(conn.encoders_ptr));
goto retry;
err_allocs:
drmFree(U642VOID(conn.prop_values_ptr));
drmFree(U642VOID(conn.props_ptr));
- drmFree(U642VOID(conn.modes_ptr));
+ if (U642VOID(conn.modes_ptr) != &stack_mode)
+ drmFree(U642VOID(conn.modes_ptr));
drmFree(U642VOID(conn.encoders_ptr));
return r;
int len, i;
struct drm_event *e;
struct drm_event_vblank *vblank;
-
+
/* The DRM read semantics guarantees that we always get only
* complete events. */
break;
vblank = (struct drm_event_vblank *) e;
evctx->vblank_handler(fd,
- vblank->sequence,
+ vblank->sequence,
vblank->tv_sec,
vblank->tv_usec,
U642VOID (vblank->user_data));
{
drmModeAtomicReqPtr new;
+ if (!old)
+ return NULL;
+
new = drmMalloc(sizeof *new);
if (!new)
return NULL;
int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
{
+ if (!base)
+ return -EINVAL;
+
if (!augment || augment->cursor == 0)
return 0;
int drmModeAtomicGetCursor(drmModeAtomicReqPtr req)
{
+ if (!req)
+ return -EINVAL;
return req->cursor;
}
void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor)
{
- req->cursor = cursor;
+ if (req)
+ req->cursor = cursor;
}
int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
uint32_t property_id,
uint64_t value)
{
+ if (!req)
+ return -EINVAL;
+
if (req->cursor >= req->size_items) {
drmModeAtomicReqItemPtr new;
int obj_idx = -1;
int ret = -1;
+ if (!req)
+ return -EINVAL;
+
if (req->cursor == 0)
return 0;