#define DRM_NODE_PRIMARY 1
#define DRM_NODE_RENDER 2
+#define memclear(s) memset(&s, 0, sizeof(s))
+
static drmServerInfoPtr drm_server_info;
void drmSetServerInfo(drmServerInfoPtr info)
drmVersionPtr retval;
drm_version_t *version = drmMalloc(sizeof(*version));
- version->name_len = 0;
- version->name = NULL;
- version->date_len = 0;
- version->date = NULL;
- version->desc_len = 0;
- version->desc = NULL;
+ memclear(version);
if (drmIoctl(fd, DRM_IOCTL_VERSION, version)) {
drmFreeKernelVersion(version);
int drmGetCap(int fd, uint64_t capability, uint64_t *value)
{
- struct drm_get_cap cap = { capability, 0 };
+ struct drm_get_cap cap;
int ret;
+ memclear(cap);
+ cap.capability = capability;
+
ret = drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap);
if (ret)
return ret;
int drmSetClientCap(int fd, uint64_t capability, uint64_t value)
{
- struct drm_set_client_cap cap = { capability, value };
+ struct drm_set_client_cap cap;
+
+ memclear(cap);
+ cap.capability = capability;
+ cap.value = value;
return drmIoctl(fd, DRM_IOCTL_SET_CLIENT_CAP, &cap);
}
{
drm_unique_t u;
- u.unique_len = 0;
- u.unique = NULL;
+ memclear(u);
if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u))
return NULL;
{
drm_unique_t u;
+ memclear(u);
u.unique = (char *)busid;
u.unique_len = strlen(busid);
{
drm_auth_t auth;
+ memclear(auth);
+
*magic = 0;
if (drmIoctl(fd, DRM_IOCTL_GET_MAGIC, &auth))
return -errno;
{
drm_auth_t auth;
+ memclear(auth);
auth.magic = magic;
if (drmIoctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth))
return -errno;
{
drm_map_t map;
+ memclear(map);
map.offset = offset;
map.size = size;
- map.handle = 0;
map.type = type;
map.flags = flags;
if (drmIoctl(fd, DRM_IOCTL_ADD_MAP, &map))
{
drm_map_t map;
+ memclear(map);
map.handle = (void *)(uintptr_t)handle;
if(drmIoctl(fd, DRM_IOCTL_RM_MAP, &map))
{
drm_buf_desc_t request;
+ memclear(request);
request.count = count;
request.size = size;
- request.low_mark = 0;
- request.high_mark = 0;
request.flags = flags;
request.agp_start = agp_offset;
drm_buf_info_t info;
int i;
- info.count = 0;
- info.list = NULL;
+ memclear(info);
if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info))
return -EINVAL;
{
drm_buf_free_t request;
+ memclear(request);
request.count = count;
request.list = list;
if (drmIoctl(fd, DRM_IOCTL_FREE_BUFS, &request))
drmBufInfoPtr retval;
int i;
- info.count = 0;
- info.list = NULL;
+ memclear(info);
if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info))
return NULL;
drmBufMapPtr retval;
int i;
- bufs.count = 0;
- bufs.list = NULL;
- bufs.virtual = NULL;
+ memclear(bufs);
if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs))
return NULL;
{
drm_lock_t lock;
+ memclear(lock);
lock.context = context;
lock.flags = 0;
if (flags & DRM_LOCK_READY) lock.flags |= _DRM_LOCK_READY;
{
drm_lock_t lock;
+ memclear(lock);
lock.context = context;
- lock.flags = 0;
return drmIoctl(fd, DRM_IOCTL_UNLOCK, &lock);
}
drm_context_t * retval;
int i;
- res.count = 0;
- res.contexts = NULL;
+ memclear(res);
if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res))
return NULL;
{
drm_ctx_t ctx;
- ctx.flags = 0; /* Modified with functions below */
+ memclear(ctx);
if (drmIoctl(fd, DRM_IOCTL_ADD_CTX, &ctx))
return -errno;
*handle = ctx.handle;
{
drm_ctx_t ctx;
+ memclear(ctx);
ctx.handle = context;
if (drmIoctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx))
return -errno;
* X server (which promises to maintain hardware context), or in the
* client-side library when buffers are swapped on behalf of two threads.
*/
+ memclear(ctx);
ctx.handle = context;
- ctx.flags = 0;
if (flags & DRM_CONTEXT_PRESERVED)
ctx.flags |= _DRM_CONTEXT_PRESERVED;
if (flags & DRM_CONTEXT_2DONLY)
{
drm_ctx_t ctx;
+ memclear(ctx);
ctx.handle = context;
if (drmIoctl(fd, DRM_IOCTL_GET_CTX, &ctx))
return -errno;
int drmDestroyContext(int fd, drm_context_t handle)
{
drm_ctx_t ctx;
+
+ memclear(ctx);
ctx.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_RM_CTX, &ctx))
return -errno;
int drmCreateDrawable(int fd, drm_drawable_t *handle)
{
drm_draw_t draw;
+
+ memclear(draw);
if (drmIoctl(fd, DRM_IOCTL_ADD_DRAW, &draw))
return -errno;
*handle = draw.handle;
int drmDestroyDrawable(int fd, drm_drawable_t handle)
{
drm_draw_t draw;
+
+ memclear(draw);
draw.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_RM_DRAW, &draw))
return -errno;
{
drm_update_draw_t update;
+ memclear(update);
update.handle = handle;
update.type = type;
update.num = num;
{
drm_agp_mode_t m;
+ memclear(mode);
m.mode = mode;
if (drmIoctl(fd, DRM_IOCTL_AGP_ENABLE, &m))
return -errno;
{
drm_agp_buffer_t b;
+ memclear(b);
*handle = DRM_AGP_NO_HANDLE;
b.size = size;
- b.handle = 0;
b.type = type;
if (drmIoctl(fd, DRM_IOCTL_AGP_ALLOC, &b))
return -errno;
{
drm_agp_buffer_t b;
- b.size = 0;
+ memclear(b);
b.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_AGP_FREE, &b))
return -errno;
{
drm_agp_binding_t b;
+ memclear(b);
b.handle = handle;
b.offset = offset;
if (drmIoctl(fd, DRM_IOCTL_AGP_BIND, &b))
{
drm_agp_binding_t b;
+ memclear(b);
b.handle = handle;
- b.offset = 0;
if (drmIoctl(fd, DRM_IOCTL_AGP_UNBIND, &b))
return -errno;
return 0;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return -errno;
return i.agp_version_major;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return -errno;
return i.agp_version_minor;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.mode;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.aperture_base;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.aperture_size;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.memory_used;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.memory_allowed;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.id_vendor;
{
drm_agp_info_t i;
+ memclear(i);
+
if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i))
return 0;
return i.id_device;
{
drm_scatter_gather_t sg;
+ memclear(sg);
+
*handle = 0;
sg.size = size;
- sg.handle = 0;
if (drmIoctl(fd, DRM_IOCTL_SG_ALLOC, &sg))
return -errno;
*handle = sg.handle;
{
drm_scatter_gather_t sg;
- sg.size = 0;
+ memclear(sg);
sg.handle = handle;
if (drmIoctl(fd, DRM_IOCTL_SG_FREE, &sg))
return -errno;
{
drm_control_t ctl;
+ memclear(ctl);
ctl.func = DRM_INST_HANDLER;
ctl.irq = irq;
if (drmIoctl(fd, DRM_IOCTL_CONTROL, &ctl))
{
drm_control_t ctl;
+ memclear(ctl);
ctl.func = DRM_UNINST_HANDLER;
ctl.irq = 0;
if (drmIoctl(fd, DRM_IOCTL_CONTROL, &ctl))
{
drm_lock_t lock;
+ memclear(lock);
lock.context = context;
- lock.flags = 0;
if (flags & DRM_LOCK_READY) lock.flags |= _DRM_LOCK_READY;
if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT;
if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
{
drm_irq_busid_t p;
+ memclear(p);
p.busnum = busnum;
p.devnum = devnum;
p.funcnum = funcnum;
{
drm_ctx_priv_map_t map;
+ memclear(map);
map.ctx_id = ctx_id;
map.handle = (void *)(uintptr_t)handle;
{
drm_ctx_priv_map_t map;
+ memclear(map);
map.ctx_id = ctx_id;
if (drmIoctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map))
{
drm_map_t map;
+ memclear(map);
map.offset = idx;
if (drmIoctl(fd, DRM_IOCTL_GET_MAP, &map))
return -errno;
{
drm_client_t client;
+ memclear(client);
client.idx = idx;
if (drmIoctl(fd, DRM_IOCTL_GET_CLIENT, &client))
return -errno;
drm_stats_t s;
unsigned i;
+ memclear(s);
if (drmIoctl(fd, DRM_IOCTL_GET_STATS, &s))
return -errno;
int retcode = 0;
drm_set_version_t sv;
+ memclear(sv);
sv.drm_di_major = version->drm_di_major;
sv.drm_di_minor = version->drm_di_minor;
sv.drm_dd_major = version->drm_dd_major;
*/
int drmCommandNone(int fd, unsigned long drmCommandIndex)
{
- void *data = NULL; /* dummy */
unsigned long request;
request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex);
- if (drmIoctl(fd, request, data)) {
+ if (drmIoctl(fd, request, NULL)) {
return -errno;
}
return 0;
int drmSetMaster(int fd)
{
- return drmIoctl(fd, DRM_IOCTL_SET_MASTER, 0);
+ return drmIoctl(fd, DRM_IOCTL_SET_MASTER, NULL);
}
int drmDropMaster(int fd)
{
- return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, 0);
+ return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, NULL);
}
char *drmGetDeviceNameFromFd(int fd)