update signed/object prop types

Signed-off-by: Rob Clark <robclark@freedesktop.org>
main
Rob Clark 2013-10-12 12:16:44 -04:00
parent c2c0346e1f
commit fb4177046d
4 changed files with 84 additions and 19 deletions

View File

@ -239,6 +239,21 @@ struct drm_mode_get_connector {
#define DRM_MODE_PROP_BLOB (1<<4) #define DRM_MODE_PROP_BLOB (1<<4)
#define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */ #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */
/* non-extended types: legacy bitmask, one bit per type: */
#define DRM_MODE_PROP_LEGACY_TYPE ( \
DRM_MODE_PROP_RANGE | \
DRM_MODE_PROP_ENUM | \
DRM_MODE_PROP_BLOB | \
DRM_MODE_PROP_BITMASK)
/* extended-types: rather than continue to consume a bit per type,
* grab a chunk of the bits to use as integer type id.
*/
#define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0
#define DRM_MODE_PROP_TYPE(n) ((n) << 6)
#define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
#define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
struct drm_mode_property_enum { struct drm_mode_property_enum {
__u64 value; __u64 value;
char name[DRM_PROP_NAME_LEN]; char name[DRM_PROP_NAME_LEN];

View File

@ -116,6 +116,10 @@ struct device {
}; };
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
static inline int64_t U642I64(uint64_t val)
{
return (int64_t)*((int64_t *)&val);
}
struct type_name { struct type_name {
int type; int type;
@ -296,32 +300,43 @@ static void dump_prop(struct device *dev, drmModePropertyPtr prop,
printf("\t\tflags:"); printf("\t\tflags:");
if (prop->flags & DRM_MODE_PROP_PENDING) if (prop->flags & DRM_MODE_PROP_PENDING)
printf(" pending"); printf(" pending");
if (prop->flags & DRM_MODE_PROP_RANGE)
printf(" range");
if (prop->flags & DRM_MODE_PROP_IMMUTABLE) if (prop->flags & DRM_MODE_PROP_IMMUTABLE)
printf(" immutable"); printf(" immutable");
if (prop->flags & DRM_MODE_PROP_ENUM) if (drm_property_type_is(prop, DRM_MODE_PROP_SIGNED_RANGE))
printf(" signed range");
if (drm_property_type_is(prop, DRM_MODE_PROP_RANGE))
printf(" range");
if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM))
printf(" enum"); printf(" enum");
if (prop->flags & DRM_MODE_PROP_BITMASK) if (drm_property_type_is(prop, DRM_MODE_PROP_BITMASK))
printf(" bitmask"); printf(" bitmask");
if (prop->flags & DRM_MODE_PROP_BLOB) if (drm_property_type_is(prop, DRM_MODE_PROP_BLOB))
printf(" blob"); printf(" blob");
if (drm_property_type_is(prop, DRM_MODE_PROP_OBJECT))
printf(" object");
printf("\n"); printf("\n");
if (prop->flags & DRM_MODE_PROP_RANGE) { if (drm_property_type_is(prop, DRM_MODE_PROP_SIGNED_RANGE)) {
printf("\t\tvalues:");
for (i = 0; i < prop->count_values; i++)
printf(" %"PRId64, U642I64(prop->values[i]));
printf("\n");
}
if (drm_property_type_is(prop, DRM_MODE_PROP_RANGE)) {
printf("\t\tvalues:"); printf("\t\tvalues:");
for (i = 0; i < prop->count_values; i++) for (i = 0; i < prop->count_values; i++)
printf(" %"PRIu64, prop->values[i]); printf(" %"PRIu64, prop->values[i]);
printf("\n"); printf("\n");
} }
if (prop->flags & DRM_MODE_PROP_ENUM) { if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM)) {
printf("\t\tenums:"); printf("\t\tenums:");
for (i = 0; i < prop->count_enums; i++) for (i = 0; i < prop->count_enums; i++)
printf(" %s=%llu", prop->enums[i].name, printf(" %s=%llu", prop->enums[i].name,
prop->enums[i].value); prop->enums[i].value);
printf("\n"); printf("\n");
} else if (prop->flags & DRM_MODE_PROP_BITMASK) { } else if (drm_property_type_is(prop, DRM_MODE_PROP_BITMASK)) {
printf("\t\tvalues:"); printf("\t\tvalues:");
for (i = 0; i < prop->count_enums; i++) for (i = 0; i < prop->count_enums; i++)
printf(" %s=0x%llx", prop->enums[i].name, printf(" %s=0x%llx", prop->enums[i].name,
@ -331,7 +346,7 @@ static void dump_prop(struct device *dev, drmModePropertyPtr prop,
assert(prop->count_enums == 0); assert(prop->count_enums == 0);
} }
if (prop->flags & DRM_MODE_PROP_BLOB) { if (drm_property_type_is(prop, DRM_MODE_PROP_BLOB)) {
printf("\t\tblobs:\n"); printf("\t\tblobs:\n");
for (i = 0; i < prop->count_blobs; i++) for (i = 0; i < prop->count_blobs; i++)
dump_blob(dev, prop->blob_ids[i]); dump_blob(dev, prop->blob_ids[i]);
@ -341,7 +356,7 @@ static void dump_prop(struct device *dev, drmModePropertyPtr prop,
} }
printf("\t\tvalue:"); printf("\t\tvalue:");
if (prop->flags & DRM_MODE_PROP_BLOB) if (drm_property_type_is(prop, DRM_MODE_PROP_BLOB))
dump_blob(dev, value); dump_blob(dev, value);
else else
printf(" %"PRIu64"\n", value); printf(" %"PRIu64"\n", value);

View File

@ -36,6 +36,10 @@
#include "xf86drmMode.h" #include "xf86drmMode.h"
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
static inline int64_t U642I64(uint64_t val)
{
return (int64_t)*((int64_t *)&val);
}
int fd; int fd;
drmModeResPtr res = NULL; drmModeResPtr res = NULL;
@ -87,8 +91,10 @@ dump_blob(uint32_t blob_id)
drmModePropertyBlobPtr blob; drmModePropertyBlobPtr blob;
blob = drmModeGetPropertyBlob(fd, blob_id); blob = drmModeGetPropertyBlob(fd, blob_id);
if (!blob) if (!blob) {
printf("\n");
return; return;
}
blob_data = blob->data; blob_data = blob->data;
@ -121,34 +127,54 @@ dump_prop(uint32_t prop_id, uint64_t value)
printf("\t\tflags:"); printf("\t\tflags:");
if (prop->flags & DRM_MODE_PROP_PENDING) if (prop->flags & DRM_MODE_PROP_PENDING)
printf(" pending"); printf(" pending");
if (prop->flags & DRM_MODE_PROP_RANGE)
printf(" range");
if (prop->flags & DRM_MODE_PROP_IMMUTABLE) if (prop->flags & DRM_MODE_PROP_IMMUTABLE)
printf(" immutable"); printf(" immutable");
if (prop->flags & DRM_MODE_PROP_ENUM) if (drm_property_type_is(prop, DRM_MODE_PROP_SIGNED_RANGE))
printf(" signed range");
if (drm_property_type_is(prop, DRM_MODE_PROP_RANGE))
printf(" range");
if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM))
printf(" enum"); printf(" enum");
if (prop->flags & DRM_MODE_PROP_BLOB) if (drm_property_type_is(prop, DRM_MODE_PROP_BITMASK))
printf(" bitmask");
if (drm_property_type_is(prop, DRM_MODE_PROP_BLOB))
printf(" blob"); printf(" blob");
if (drm_property_type_is(prop, DRM_MODE_PROP_OBJECT))
printf(" object");
printf("\n"); printf("\n");
if (prop->flags & DRM_MODE_PROP_RANGE) {
if (drm_property_type_is(prop, DRM_MODE_PROP_SIGNED_RANGE)) {
printf("\t\tvalues:");
for (i = 0; i < prop->count_values; i++)
printf(" %"PRId64, U642I64(prop->values[i]));
printf("\n");
}
if (drm_property_type_is(prop, DRM_MODE_PROP_RANGE)) {
printf("\t\tvalues:"); printf("\t\tvalues:");
for (i = 0; i < prop->count_values; i++) for (i = 0; i < prop->count_values; i++)
printf(" %"PRIu64, prop->values[i]); printf(" %"PRIu64, prop->values[i]);
printf("\n"); printf("\n");
} }
if (prop->flags & DRM_MODE_PROP_ENUM) { if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM)) {
printf("\t\tenums:"); printf("\t\tenums:");
for (i = 0; i < prop->count_enums; i++) for (i = 0; i < prop->count_enums; i++)
printf(" %s=%llu", prop->enums[i].name, printf(" %s=%llu", prop->enums[i].name,
prop->enums[i].value); prop->enums[i].value);
printf("\n"); printf("\n");
} else if (drm_property_type_is(prop, DRM_MODE_PROP_BITMASK)) {
printf("\t\tvalues:");
for (i = 0; i < prop->count_enums; i++)
printf(" %s=0x%llx", prop->enums[i].name,
(1LL << prop->enums[i].value));
printf("\n");
} else { } else {
assert(prop->count_enums == 0); assert(prop->count_enums == 0);
} }
if (prop->flags & DRM_MODE_PROP_BLOB) { if (drm_property_type_is(prop, DRM_MODE_PROP_BLOB)) {
printf("\t\tblobs:\n"); printf("\t\tblobs:\n");
for (i = 0; i < prop->count_blobs; i++) for (i = 0; i < prop->count_blobs; i++)
dump_blob(prop->blob_ids[i]); dump_blob(prop->blob_ids[i]);
@ -158,7 +184,7 @@ dump_prop(uint32_t prop_id, uint64_t value)
} }
printf("\t\tvalue:"); printf("\t\tvalue:");
if (prop->flags & DRM_MODE_PROP_BLOB) if (drm_property_type_is(prop, DRM_MODE_PROP_BLOB))
dump_blob(value); dump_blob(value);
else else
printf(" %"PRIu64"\n", value); printf(" %"PRIu64"\n", value);

View File

@ -240,6 +240,15 @@ typedef struct _drmModeProperty {
uint32_t *blob_ids; /* store the blob IDs */ uint32_t *blob_ids; /* store the blob IDs */
} drmModePropertyRes, *drmModePropertyPtr; } drmModePropertyRes, *drmModePropertyPtr;
static inline int drm_property_type_is(drmModePropertyPtr property,
uint32_t type)
{
/* instanceof for props.. handles extended type vs original types: */
if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
return property->flags & type;
}
typedef struct _drmModeCrtc { typedef struct _drmModeCrtc {
uint32_t crtc_id; uint32_t crtc_id;
uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */ uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */