summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drmMode.c75
-rw-r--r--libdrm/xf86drmMode.h6
2 files changed, 45 insertions, 36 deletions
diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index bb7be13c..e5191d8c 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -42,6 +42,9 @@
#include <drm.h>
#include <string.h>
+#define U642VOID(x) ((void *)(unsigned long)(x))
+#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
+
/*
* Util functions
*/
@@ -149,11 +152,11 @@ drmModeResPtr drmModeGetResources(int fd)
return 0;
if (res.count_fbs)
- res.fb_id = drmMalloc(res.count_fbs*sizeof(uint32_t));
+ res.fb_id_ptr = VOID2U64(drmMalloc(res.count_fbs*sizeof(uint32_t)));
if (res.count_crtcs)
- res.crtc_id = drmMalloc(res.count_crtcs*sizeof(uint32_t));
+ res.crtc_id_ptr = VOID2U64(drmMalloc(res.count_crtcs*sizeof(uint32_t)));
if (res.count_outputs)
- res.output_id = drmMalloc(res.count_outputs*sizeof(uint32_t));
+ res.output_id_ptr = VOID2U64(drmMalloc(res.count_outputs*sizeof(uint32_t)));
if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) {
r = NULL;
@@ -168,18 +171,22 @@ drmModeResPtr drmModeGetResources(int fd)
if (!(r = drmMalloc(sizeof(*r))))
return 0;
+ r->min_width = res.min_width;
+ r->max_width = res.max_width;
+ r->min_height = res.min_height;
+ r->max_height = res.max_height;
r->count_fbs = res.count_fbs;
r->count_crtcs = res.count_crtcs;
r->count_outputs = res.count_outputs;
/* TODO we realy should test if these allocs fails. */
- r->fbs = drmAllocCpy(res.fb_id, res.count_fbs, sizeof(uint32_t));
- r->crtcs = drmAllocCpy(res.crtc_id, res.count_crtcs, sizeof(uint32_t));
- r->outputs = drmAllocCpy(res.output_id, res.count_outputs, sizeof(uint32_t));
+ r->fbs = drmAllocCpy(U642VOID(res.fb_id_ptr), res.count_fbs, sizeof(uint32_t));
+ r->crtcs = drmAllocCpy(U642VOID(res.crtc_id_ptr), res.count_crtcs, sizeof(uint32_t));
+ r->outputs = drmAllocCpy(U642VOID(res.output_id_ptr), res.count_outputs, sizeof(uint32_t));
err_allocs:
- drmFree(res.fb_id);
- drmFree(res.crtc_id);
- drmFree(res.output_id);
+ drmFree(U642VOID(res.fb_id_ptr));
+ drmFree(U642VOID(res.crtc_id_ptr));
+ drmFree(U642VOID(res.output_id_ptr));
return r;
}
@@ -297,7 +304,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
crtc.y = y;
crtc.crtc_id = crtcId;
crtc.fb_id = bufferId;
- crtc.set_outputs = outputs;
+ crtc.set_outputs_ptr = VOID2U64(outputs);
crtc.count_outputs = count;
if (mode) {
memcpy(&crtc.mode, mode, sizeof(struct drm_mode_modeinfo));
@@ -324,21 +331,21 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id)
out.count_clones = 0;
out.clones = 0;
out.count_modes = 0;
- out.modes = 0;
+ out.modes_ptr = 0;
out.count_props = 0;
- out.props = NULL;
- out.prop_values = NULL;
+ out.props_ptr = 0;
+ out.prop_values_ptr = 0;
if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out))
return 0;
if (out.count_props) {
- out.props = drmMalloc(out.count_props*sizeof(uint32_t));
- out.prop_values = drmMalloc(out.count_props*sizeof(uint32_t));
+ out.props_ptr = VOID2U64(drmMalloc(out.count_props*sizeof(uint32_t)));
+ out.prop_values_ptr = VOID2U64(drmMalloc(out.count_props*sizeof(uint64_t)));
}
if (out.count_modes)
- out.modes = drmMalloc(out.count_modes*sizeof(struct drm_mode_modeinfo));
+ out.modes_ptr = VOID2U64(drmMalloc(out.count_modes*sizeof(struct drm_mode_modeinfo)));
if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out))
goto err_allocs;
@@ -360,16 +367,16 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id)
r->crtcs = out.crtcs;
r->clones = out.clones;
r->count_props = out.count_props;
- r->props = drmAllocCpy(out.props, out.count_props, sizeof(uint32_t));
- r->prop_values = drmAllocCpy(out.prop_values, out.count_props, sizeof(uint32_t));
- r->modes = drmAllocCpy(out.modes, out.count_modes, sizeof(struct drm_mode_modeinfo));
+ r->props = drmAllocCpy(U642VOID(out.props_ptr), out.count_props, sizeof(uint32_t));
+ r->prop_values = drmAllocCpy(U642VOID(out.prop_values_ptr), out.count_props, sizeof(uint64_t));
+ r->modes = drmAllocCpy(U642VOID(out.modes_ptr), out.count_modes, sizeof(struct drm_mode_modeinfo));
strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN);
r->name[DRM_OUTPUT_NAME_LEN-1] = 0;
err_allocs:
- drmFree(out.prop_values);
- drmFree(out.props);
- drmFree(out.modes);
+ drmFree(U642VOID(out.prop_values_ptr));
+ drmFree(U642VOID(out.props_ptr));
+ drmFree(U642VOID(out.modes_ptr));
return r;
}
@@ -401,20 +408,20 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
drmModePropertyPtr r;
prop.prop_id = property_id;
- prop.count_enums = 0;
+ prop.count_enum_blobs = 0;
prop.count_values = 0;
prop.flags = 0;
- prop.enums = NULL;
- prop.values = NULL;
+ prop.enum_blob_ptr = 0;
+ prop.values_ptr = 0;
if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop))
return 0;
if (prop.count_values)
- prop.values = drmMalloc(prop.count_values * sizeof(uint32_t));
+ prop.values_ptr = VOID2U64(drmMalloc(prop.count_values * sizeof(uint64_t)));
- if (prop.count_enums)
- prop.enums = drmMalloc(prop.count_enums * sizeof(struct drm_mode_property_enum));
+ if (prop.count_enum_blobs)
+ prop.enum_blob_ptr = VOID2U64(drmMalloc(prop.count_enum_blobs * sizeof(struct drm_mode_property_enum)));
if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) {
r = NULL;
@@ -426,16 +433,16 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
r->prop_id = prop.prop_id;
r->count_values = prop.count_values;
- r->count_enums = prop.count_enums;
-
- r->values = drmAllocCpy(prop.values, prop.count_values, sizeof(uint32_t));
- r->enums = drmAllocCpy(prop.enums, prop.count_enums, sizeof(struct drm_mode_property_enum));
+ r->count_enums = prop.count_enum_blobs;
+ r->flags = prop.flags;
+ r->values = drmAllocCpy(U642VOID(prop.values_ptr), prop.count_values, sizeof(uint64_t));
+ r->enums = drmAllocCpy(U642VOID(prop.enum_blob_ptr), prop.count_enum_blobs, sizeof(struct drm_mode_property_enum));
strncpy(r->name, prop.name, DRM_PROP_NAME_LEN);
r->name[DRM_PROP_NAME_LEN-1] = 0;
err_allocs:
- drmFree(prop.values);
- drmFree(prop.enums);
+ drmFree(U642VOID(prop.values_ptr));
+ drmFree(U642VOID(prop.enum_blob_ptr));
return r;
}
diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h
index a1d717f9..ec77174b 100644
--- a/libdrm/xf86drmMode.h
+++ b/libdrm/xf86drmMode.h
@@ -63,6 +63,8 @@ typedef struct _drmModeRes {
int count_outputs;
uint32_t *outputs;
+ uint32_t min_width, max_width;
+ uint32_t min_height, max_height;
} drmModeRes, *drmModeResPtr;
typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr;
@@ -72,7 +74,7 @@ typedef struct _drmModeProperty {
unsigned int flags;
unsigned char name[DRM_PROP_NAME_LEN];
int count_values;
- uint32_t *values;
+ uint64_t *values;
int count_enums;
struct drm_mode_property_enum *enums;
@@ -132,7 +134,7 @@ typedef struct _drmModeOutput {
int count_props;
uint32_t *props; /**< List of property ids */
- uint32_t *prop_values; /**< List of property values */
+ uint64_t *prop_values; /**< List of property values */
} drmModeOutput, *drmModeOutputPtr;