summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2007-12-05 16:03:05 +1000
committerDave Airlie <airlied@redhat.com>2007-12-05 16:03:05 +1000
commit1a6c95ef711fce807659ab5e4fe480d65ac233b6 (patch)
treec50176cc24a94b527a623b99caa9896cb4a4350f
parentf7432d187e4b5e13c9e450bf12d5ab8c18ea5146 (diff)
arrgggh.. make all ioctl structs 32/64-bit compatible hopefully.
This also starts to add blob property support. someone needs to check this work for other things like ppc/x86 alignment diffs
-rw-r--r--libdrm/xf86drmMode.c75
-rw-r--r--libdrm/xf86drmMode.h6
-rw-r--r--linux-core/drm_crtc.c163
-rw-r--r--linux-core/drm_crtc.h23
-rw-r--r--linux-core/intel_crt.c2
-rw-r--r--shared-core/drm.h48
-rw-r--r--tests/mode/modetest.c21
7 files changed, 222 insertions, 116 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;
diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c
index 26aa5206..c2680319 100644
--- a/linux-core/drm_crtc.c
+++ b/linux-core/drm_crtc.c
@@ -722,7 +722,11 @@ void drm_mode_config_init(struct drm_device *dev)
INIT_LIST_HEAD(&dev->mode_config.crtc_list);
INIT_LIST_HEAD(&dev->mode_config.output_list);
INIT_LIST_HEAD(&dev->mode_config.property_list);
+ INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
idr_init(&dev->mode_config.crtc_idr);
+ dev->mode_config.edid_property = drm_property_create(dev,
+ DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE,
+ "EDID", 0);
}
EXPORT_SYMBOL(drm_mode_config_init);
@@ -1013,7 +1017,7 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info,
if (crtc_info->x != crtc->x || crtc_info->y != crtc->y)
changed = true;
- if (new_mode && (crtc->mode.mode_id != new_mode->mode_id))
+ if (new_mode && !drm_mode_equal(new_mode, &crtc->mode))
changed = true;
list_for_each_entry(output, &dev->mode_config.output_list, head) {
@@ -1152,6 +1156,9 @@ int drm_mode_getresources(struct drm_device *dev,
int crtc_count = 0;
int fb_count = 0;
int copied = 0;
+ uint32_t __user *fb_id;
+ uint32_t __user *crtc_id;
+ uint32_t __user *output_id;
mutex_lock(&dev->mode_config.mutex);
@@ -1164,12 +1171,18 @@ int drm_mode_getresources(struct drm_device *dev,
list_for_each(lh, &dev->mode_config.output_list)
output_count++;
+ card_res->max_height = dev->mode_config.max_height;
+ card_res->min_height = dev->mode_config.min_height;
+ card_res->max_width = dev->mode_config.max_width;
+ card_res->min_width = dev->mode_config.min_width;
+
/* handle this in 4 parts */
/* FBs */
if (card_res->count_fbs >= fb_count) {
copied = 0;
+ fb_id = (uint32_t *)(unsigned long)card_res->fb_id_ptr;
list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
- if (put_user(fb->id, card_res->fb_id + copied)) {
+ if (put_user(fb->id, fb_id + copied)) {
ret = -EFAULT;
goto out;
}
@@ -1181,9 +1194,10 @@ int drm_mode_getresources(struct drm_device *dev,
/* CRTCs */
if (card_res->count_crtcs >= crtc_count) {
copied = 0;
+ crtc_id = (uint32_t *)(unsigned long)card_res->crtc_id_ptr;
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head){
DRM_DEBUG("CRTC ID is %d\n", crtc->id);
- if (put_user(crtc->id, card_res->crtc_id + copied)) {
+ if (put_user(crtc->id, crtc_id + copied)) {
ret = -EFAULT;
goto out;
}
@@ -1196,10 +1210,11 @@ int drm_mode_getresources(struct drm_device *dev,
/* Outputs */
if (card_res->count_outputs >= output_count) {
copied = 0;
+ output_id = (uint32_t *)(unsigned long)card_res->output_id_ptr;
list_for_each_entry(output, &dev->mode_config.output_list,
head) {
DRM_DEBUG("OUTPUT ID is %d\n", output->id);
- if (put_user(output->id, card_res->output_id + copied)) {
+ if (put_user(output->id, output_id + copied)) {
ret = -EFAULT;
goto out;
}
@@ -1211,7 +1226,6 @@ int drm_mode_getresources(struct drm_device *dev,
DRM_DEBUG("Counted %d %d\n", card_res->count_crtcs,
card_res->count_outputs);
-
out:
mutex_unlock(&dev->mode_config.mutex);
return ret;
@@ -1307,6 +1321,9 @@ int drm_mode_getoutput(struct drm_device *dev,
int copied = 0;
int i;
struct drm_mode_modeinfo u_mode;
+ struct drm_mode_modeinfo __user *mode_ptr;
+ uint32_t __user *prop_ptr;
+ uint64_t __user *prop_values;
memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
@@ -1349,9 +1366,10 @@ int drm_mode_getoutput(struct drm_device *dev,
if ((out_resp->count_modes >= mode_count) && mode_count) {
copied = 0;
+ mode_ptr = (struct drm_mode_modeinfo *)(unsigned long)out_resp->modes_ptr;
list_for_each_entry(mode, &output->modes, head) {
drm_crtc_convert_to_umode(&u_mode, mode);
- if (copy_to_user(out_resp->modes + copied,
+ if (copy_to_user(mode_ptr + copied,
&u_mode, sizeof(u_mode))) {
ret = -EFAULT;
goto out;
@@ -1364,14 +1382,16 @@ int drm_mode_getoutput(struct drm_device *dev,
if ((out_resp->count_props >= props_count) && props_count) {
copied = 0;
+ prop_ptr = (uint32_t *)(unsigned long)(out_resp->props_ptr);
+ prop_values = (uint64_t *)(unsigned long)(out_resp->prop_values_ptr);
for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) {
if (output->property_ids[i] != 0) {
- if (put_user(output->property_ids[i], out_resp->props + copied)) {
+ if (put_user(output->property_ids[i], prop_ptr + copied)) {
ret = -EFAULT;
goto out;
}
- if (put_user(output->property_values[i], out_resp->prop_values + copied)) {
+ if (put_user(output->property_values[i], prop_values + copied)) {
ret = -EFAULT;
goto out;
}
@@ -1410,10 +1430,10 @@ int drm_mode_setcrtc(struct drm_device *dev,
struct drm_crtc *crtc;
struct drm_output **output_set = NULL, *output;
struct drm_framebuffer *fb = NULL;
- struct drm_display_mode mode;
- int mode_valid = 0;
+ struct drm_display_mode *mode = NULL;
int ret = 0;
int i;
+ uint32_t __user *set_outputs_ptr;
mutex_lock(&dev->mode_config.mutex);
crtc = idr_find(&dev->mode_config.crtc_idr, crtc_req->crtc_id);
@@ -1434,18 +1454,17 @@ int drm_mode_setcrtc(struct drm_device *dev,
}
}
- mode_valid = 1;
- drm_crtc_convert_umode(&mode, &crtc_req->mode);
- } else
- mode_valid = 0;
+ mode = drm_mode_create(dev);
+ drm_crtc_convert_umode(mode, &crtc_req->mode);
+ }
- if (crtc_req->count_outputs == 0 && mode_valid) {
+ if (crtc_req->count_outputs == 0 && mode) {
DRM_DEBUG("Count outputs is 0 but mode set\n");
ret = -EINVAL;
goto out;
}
- if (crtc_req->count_outputs > 0 && !mode_valid && !fb) {
+ if (crtc_req->count_outputs > 0 && !mode && !fb) {
DRM_DEBUG("Count outputs is %d but no mode or fb set\n", crtc_req->count_outputs);
ret = -EINVAL;
goto out;
@@ -1461,7 +1480,8 @@ int drm_mode_setcrtc(struct drm_device *dev,
}
for (i = 0; i < crtc_req->count_outputs; i++) {
- if (get_user(out_id, &crtc_req->set_outputs[i])) {
+ set_outputs_ptr = (uint32_t *)(unsigned long)crtc_req->set_outputs_ptr;
+ if (get_user(out_id, &set_outputs_ptr[i])) {
ret = -EFAULT;
goto out;
}
@@ -1477,11 +1497,7 @@ int drm_mode_setcrtc(struct drm_device *dev,
}
}
- if (mode_valid) {
- ret = drm_crtc_set_config(crtc, crtc_req, &mode, output_set, fb);
- } else {
- ret = drm_crtc_set_config(crtc, crtc_req, NULL, output_set, fb);
- }
+ ret = drm_crtc_set_config(crtc, crtc_req, mode, output_set, fb);
out:
mutex_unlock(&dev->mode_config.mutex);
@@ -1847,15 +1863,17 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
property = kzalloc(sizeof(struct drm_output), GFP_KERNEL);
if (!property)
return NULL;
-
- property->values = kzalloc(sizeof(uint32_t)*num_values, GFP_KERNEL);
- if (!property->values)
- goto fail;
+
+ if (num_values) {
+ property->values = kzalloc(sizeof(uint64_t)*num_values, GFP_KERNEL);
+ if (!property->values)
+ goto fail;
+ }
property->id = drm_idr_get(dev, property);
property->flags = flags;
property->num_values = num_values;
- INIT_LIST_HEAD(&property->enum_list);
+ INIT_LIST_HEAD(&property->enum_blob_list);
if (name)
strncpy(property->name, name, DRM_PROP_NAME_LEN);
@@ -1869,15 +1887,15 @@ fail:
EXPORT_SYMBOL(drm_property_create);
int drm_property_add_enum(struct drm_property *property, int index,
- uint32_t value, const char *name)
+ uint64_t value, const char *name)
{
struct drm_property_enum *prop_enum;
if (!(property->flags & DRM_MODE_PROP_ENUM))
return -EINVAL;
- if (!list_empty(&property->enum_list)) {
- list_for_each_entry(prop_enum, &property->enum_list, head) {
+ if (!list_empty(&property->enum_blob_list)) {
+ list_for_each_entry(prop_enum, &property->enum_blob_list, head) {
if (prop_enum->value == value) {
strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN);
prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0';
@@ -1895,7 +1913,7 @@ int drm_property_add_enum(struct drm_property *property, int index,
prop_enum->value = value;
property->values[index] = value;
- list_add_tail(&prop_enum->head, &property->enum_list);
+ list_add_tail(&prop_enum->head, &property->enum_blob_list);
return 0;
}
EXPORT_SYMBOL(drm_property_add_enum);
@@ -1904,12 +1922,13 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property)
{
struct drm_property_enum *prop_enum, *pt;
- list_for_each_entry_safe(prop_enum, pt, &property->enum_list, head) {
+ list_for_each_entry_safe(prop_enum, pt, &property->enum_blob_list, head) {
list_del(&prop_enum->head);
kfree(prop_enum);
}
- kfree(property->values);
+ if (property->num_values)
+ kfree(property->values);
drm_idr_put(dev, property->id);
list_del(&property->head);
kfree(property);
@@ -1918,7 +1937,7 @@ EXPORT_SYMBOL(drm_property_destroy);
int drm_output_attach_property(struct drm_output *output,
- struct drm_property *property, int init_val)
+ struct drm_property *property, uint64_t init_val)
{
int i;
@@ -1942,10 +1961,14 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
struct drm_mode_get_property *out_resp = data;
struct drm_property *property;
int enum_count = 0;
+ int blob_count = 0;
int value_count = 0;
int ret = 0, i;
int copied;
struct drm_property_enum *prop_enum;
+ struct drm_property_enum __user *enum_ptr;
+ struct drm_property_blob *prop_blob;
+ uint64_t __user *values_ptr;
mutex_lock(&dev->mode_config.mutex);
property = idr_find(&dev->mode_config.crtc_idr, out_resp->prop_id);
@@ -1954,9 +1977,13 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
goto done;
}
-
- list_for_each_entry(prop_enum, &property->enum_list, head)
- enum_count++;
+ if (property->flags & DRM_MODE_PROP_ENUM) {
+ list_for_each_entry(prop_enum, &property->enum_blob_list, head)
+ enum_count++;
+ } else if (property->flags & DRM_MODE_PROP_BLOB) {
+ list_for_each_entry(prop_blob, &property->enum_blob_list, head)
+ blob_count++;
+ }
value_count = property->num_values;
@@ -1965,8 +1992,9 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
out_resp->flags = property->flags;
if ((out_resp->count_values >= value_count) && value_count) {
+ values_ptr = (uint64_t *)(unsigned long)out_resp->values_ptr;
for (i = 0; i < value_count; i++) {
- if (put_user(property->values[i], out_resp->values + i)) {
+ if (put_user(property->values[i], values_ptr + i)) {
ret = -EFAULT;
goto done;
}
@@ -1974,10 +2002,30 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
}
out_resp->count_values = value_count;
- if ((out_resp->count_enums >= enum_count) && enum_count) {
+ if ((out_resp->count_enum_blobs >= enum_count) && enum_count && (property->flags & DRM_MODE_PROP_ENUM)) {
+ copied = 0;
+ enum_ptr = (struct drm_property_enum *)(unsigned long)out_resp->enum_blob_ptr;
+ list_for_each_entry(prop_enum, &property->enum_blob_list, head) {
+ if (put_user(prop_enum->value, &enum_ptr[copied].value)) {
+ ret = -EFAULT;
+ goto done;
+ }
+
+ if (copy_to_user(&enum_ptr[copied].name,
+ prop_enum->name, DRM_PROP_NAME_LEN)) {
+ ret = -EFAULT;
+ goto done;
+ }
+ copied++;
+ }
+ }
+ out_resp->count_enum_blobs = enum_count;
+
+#if 0
+ if ((out_resp->count_blobs >= enum_count) && blob_count && (property->flags & DRM_MODE_PROP_BLOB)) {
copied = 0;
- list_for_each_entry(prop_enum, &property->enum_list, head) {
- if (put_user(prop_enum->value, &out_resp->enums[copied].value)) {
+ list_for_each_entry(prop_blob, &property->enum_list, head) {
+ if (put_user(prop_enum->value, &out_resp->blobs[copied].value)) {
ret = -EFAULT;
goto done;
}
@@ -1991,8 +2039,39 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
}
}
out_resp->count_enums = enum_count;
-
+#endif
done:
mutex_unlock(&dev->mode_config.mutex);
return ret;
}
+
+static int drm_property_create_blob(struct drm_device *dev, int length,
+ void *data)
+{
+ struct drm_property_blob *blob;
+
+ if (!length || !data)
+ return -EINVAL;
+
+ blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
+ if (!blob)
+ return -EINVAL;
+
+ blob->data = (void *)((char *)blob + sizeof(struct drm_property_blob));
+ blob->length = length;
+
+ memcpy(blob->data, data, length);
+
+ blob->id = drm_idr_get(dev, blob);
+
+ list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
+ return blob->id;
+}
+
+static void drm_property_destroy_blob(struct drm_device *dev,
+ struct drm_property_blob *blob)
+{
+ drm_idr_put(dev, blob->id);
+ list_del(&blob->head);
+ kfree(blob);
+}
diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h
index 90d6104f..d028f75f 100644
--- a/linux-core/drm_crtc.h
+++ b/linux-core/drm_crtc.h
@@ -234,9 +234,16 @@ struct drm_framebuffer {
struct list_head filp_head;
};
+struct drm_property_blob {
+ struct list_head head;
+ unsigned int id;
+ unsigned int length;
+ void *data;
+};
+
struct drm_property_enum {
struct list_head head;
- uint32_t value;
+ uint64_t value;
unsigned char name[DRM_PROP_NAME_LEN];
};
@@ -246,9 +253,9 @@ struct drm_property {
uint32_t flags;
char name[DRM_PROP_NAME_LEN];
uint32_t num_values;
- uint32_t *values;
+ uint64_t *values;
- struct list_head enum_list;
+ struct list_head enum_blob_list;
};
struct drm_crtc;
@@ -451,7 +458,7 @@ struct drm_output {
struct list_head user_modes;
u32 property_ids[DRM_OUTPUT_MAX_PROPERTY];
- u32 property_values[DRM_OUTPUT_MAX_PROPERTY];
+ uint64_t property_values[DRM_OUTPUT_MAX_PROPERTY];
};
/**
@@ -492,6 +499,10 @@ struct drm_mode_config {
/* DGA stuff? */
struct drm_mode_config_funcs *funcs;
unsigned long fb_base;
+
+ /* pointers to standard properties */
+ struct list_head property_blob_list;
+ struct drm_property *edid_property;
};
struct drm_output *drm_output_create(struct drm_device *dev,
@@ -549,12 +560,12 @@ extern bool drm_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mo
int x, int y);
extern int drm_output_attach_property(struct drm_output *output,
- struct drm_property *property, int init_val);
+ struct drm_property *property, uint64_t init_val);
extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
const char *name, int num_values);
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
extern int drm_property_add_enum(struct drm_property *property, int index,
- uint32_t value, const char *name);
+ uint64_t value, const char *name);
/* IOCTLs */
extern int drm_mode_getresources(struct drm_device *dev,
diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c
index 29c2e611..d3ad4654 100644
--- a/linux-core/intel_crt.c
+++ b/linux-core/intel_crt.c
@@ -245,4 +245,6 @@ void intel_crt_init(struct drm_device *dev)
output->driver_private = intel_output;
output->interlace_allowed = 0;
output->doublescan_allowed = 0;
+
+ drm_output_attach_property(output, dev->mode_config.edid_property, 0);
}
diff --git a/shared-core/drm.h b/shared-core/drm.h
index f4f75cf5..6317f142 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -920,18 +920,19 @@ struct drm_mode_modeinfo {
};
struct drm_mode_card_res {
-
+ uint64_t fb_id_ptr;
+ uint64_t crtc_id_ptr;
+ uint64_t output_id_ptr;
int count_fbs;
- unsigned int __user *fb_id;
-
int count_crtcs;
- unsigned int __user *crtc_id;
-
int count_outputs;
- unsigned int __user *output_id;
+ int min_width, max_width;
+ int min_height, max_height;
};
struct drm_mode_crtc {
+ uint64_t set_outputs_ptr;
+
unsigned int crtc_id; /**< Id */
unsigned int fb_id; /**< Id of framebuffer */
@@ -942,9 +943,6 @@ struct drm_mode_crtc {
int count_possibles;
unsigned int possibles; /**< Outputs that can be connected */
-
- unsigned int __user *set_outputs; /**< Outputs to be connected */
-
int gamma_size;
int mode_valid;
struct drm_mode_modeinfo mode;
@@ -952,6 +950,12 @@ struct drm_mode_crtc {
struct drm_mode_get_output {
+ uint64_t modes_ptr;
+ uint64_t props_ptr;
+ uint64_t prop_values_ptr;
+
+ int count_modes;
+ int count_props;
unsigned int output; /**< Id */
unsigned int crtc; /**< Id of crtc */
unsigned char name[DRM_OUTPUT_NAME_LEN];
@@ -959,42 +963,37 @@ struct drm_mode_get_output {
unsigned int connection;
unsigned int mm_width, mm_height; /**< HxW in millimeters */
unsigned int subpixel;
-
int count_crtcs;
- unsigned int crtcs; /**< possible crtc to connect to */
-
int count_clones;
+ unsigned int crtcs; /**< possible crtc to connect to */
unsigned int clones; /**< list of clones */
-
- int count_modes;
- struct drm_mode_modeinfo *modes;
-
- int count_props;
- unsigned int __user *props;
- unsigned int __user *prop_values;
};
#define DRM_MODE_PROP_PENDING (1<<0)
#define DRM_MODE_PROP_RANGE (1<<1)
#define DRM_MODE_PROP_IMMUTABLE (1<<2)
#define DRM_MODE_PROP_ENUM (1<<3) // enumerated type with text strings
+#define DRM_MODE_PROP_BLOB (1<<4)
struct drm_mode_property_enum {
- uint32_t value;
+ uint64_t value;
unsigned char name[DRM_PROP_NAME_LEN];
};
+
+struct drm_mode_property_blob {
+ uint32_t length;
+};
struct drm_mode_get_property {
+ uint64_t values_ptr;
+ uint64_t enum_blob_ptr;
unsigned int prop_id;
unsigned int flags;
unsigned char name[DRM_PROP_NAME_LEN];
int count_values;
- uint32_t __user *values;
-
- int count_enums;
- struct drm_mode_property_enum *enums;
+ int count_enum_blobs;
};
struct drm_mode_fb_cmd {
@@ -1111,6 +1110,7 @@ struct drm_mode_mode_cmd {
#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int)
#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd)
+#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_propblob)
#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd)
#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd)
diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c
index 1d5002b0..46f88d82 100644
--- a/tests/mode/modetest.c
+++ b/tests/mode/modetest.c
@@ -76,16 +76,21 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id)
printf("\n\tenums %d: \n", props->count_enums);
- for (j = 0; j < props->count_enums; j++) {
- if (output->prop_values[i] == props->enums[j].value)
- name = props->enums[j].name;
- printf("\t\t%d = %s\n", props->enums[j].value, props->enums[j].name);
- }
+ if (prop->flags & DRM_MODE_PROP_BLOB) {
+
- if (props->count_enums && name) {
- printf("\toutput property name %s %s\n", props->name, name);
} else {
- printf("\toutput property id %s %i\n", props->name, output->prop_values[i]);
+ for (j = 0; j < props->count_enums; j++) {
+ if (output->prop_values[i] == props->enums[j].value)
+ name = props->enums[j].name;
+ printf("\t\t%d = %s\n", props->enums[j].value, props->enums[j].name);
+ }
+
+ if (props->count_enums && name) {
+ printf("\toutput property name %s %s\n", props->name, name);
+ } else {
+ printf("\toutput property id %s %i\n", props->name, output->prop_values[i]);
+ }
}
drmModeFreeProperty(props);