Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For rob #1

Open
wants to merge 9 commits into
base: properties
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/drm/drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ struct drm_prime_handle {
#define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane)
#define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane)
#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)

/**
* Device specific ioctls should only be in their respective headers
Expand Down
25 changes: 25 additions & 0 deletions include/drm/drm_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ struct drm_mode_get_connector {
#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)
#define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */

struct drm_mode_property_enum {
__u64 value;
Expand All @@ -250,6 +251,30 @@ struct drm_mode_connector_set_property {
__u32 connector_id;
};

#define DRM_MODE_OBJECT_CRTC 0xcccccccc
#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
#define DRM_MODE_OBJECT_MODE 0xdededede
#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee

struct drm_mode_obj_get_properties {
__u64 props_ptr;
__u64 prop_values_ptr;
__u32 count_props;
__u32 obj_id;
__u32 obj_type;
};

struct drm_mode_obj_set_property {
__u64 value;
__u32 prop_id;
__u32 obj_id;
__u32 obj_type;
};

struct drm_mode_get_blob {
__u32 blob_id;
__u32 length;
Expand Down
1 change: 1 addition & 0 deletions tests/kmstest/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ char *drivers[] = {
"radeon",
"nouveau",
"vmwgfx",
"omapdrm",
NULL
};

Expand Down
157 changes: 133 additions & 24 deletions tests/modetest/modetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
Expand Down Expand Up @@ -71,7 +72,7 @@ struct type_name {

#define type_name_fn(res) \
char * res##_str(int type) { \
int i; \
unsigned int i; \
for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \
if (res##_names[i].type == type) \
return res##_names[i].name; \
Expand Down Expand Up @@ -145,7 +146,7 @@ void dump_encoders(void)

void dump_mode(drmModeModeInfo *mode)
{
printf(" %s %d %d %d %d %d %d %d %d %d\n",
printf("\t%s %d %d %d %d %d %d %d %d %d\n",
mode->name,
mode->vrefresh,
mode->hdisplay,
Expand All @@ -159,16 +160,95 @@ void dump_mode(drmModeModeInfo *mode)
}

static void
dump_props(drmModeConnector *connector)
dump_blob(uint32_t blob_id)
{
uint32_t i;
unsigned char *blob_data;
drmModePropertyBlobPtr blob;

blob = drmModeGetPropertyBlob(fd, blob_id);
blob_data = blob->data;

for (i = 0; i < blob->length; i++) {
if (i % 16 == 0)
printf("\n\t\t\t");
printf("%.2hhx", blob_data[i]);
}
printf("\n");

drmModeFreePropertyBlob(blob);
}

static void
dump_prop(uint32_t prop_id, uint64_t value)
{
drmModePropertyPtr props;
int i;
drmModePropertyPtr prop;

prop = drmModeGetProperty(fd, prop_id);

printf("\t%d", prop_id);
if (!prop) {
printf("\n");
return;
}

printf(" %s:\n", prop->name);

printf("\t\tflags:");
if (prop->flags & DRM_MODE_PROP_PENDING)
printf(" pending");
if (prop->flags & DRM_MODE_PROP_RANGE)
printf(" range");
if (prop->flags & DRM_MODE_PROP_IMMUTABLE)
printf(" immutable");
if (prop->flags & DRM_MODE_PROP_ENUM)
printf(" enum");
if (prop->flags & DRM_MODE_PROP_BITMASK)
printf(" bitmask");
if (prop->flags & DRM_MODE_PROP_BLOB)
printf(" blob");
printf("\n");

if (prop->flags & DRM_MODE_PROP_RANGE) {
printf("\t\tvalues:");
for (i = 0; i < prop->count_values; i++)
printf(" %"PRIu64, prop->values[i]);
printf("\n");
}

if (prop->flags & DRM_MODE_PROP_ENUM) {
printf("\t\tenums:");
for (i = 0; i < prop->count_enums; i++)
printf(" %s=%llu", prop->enums[i].name,
prop->enums[i].value);
printf("\n");
} else if (prop->flags & 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 {
assert(prop->count_enums == 0);
}

for (i = 0; i < connector->count_props; i++) {
props = drmModeGetProperty(fd, connector->props[i]);
printf("\t%s, flags %d\n", props->name, props->flags);
drmModeFreeProperty(props);
if (prop->flags & DRM_MODE_PROP_BLOB) {
printf("\t\tblobs:\n");
for (i = 0; i < prop->count_blobs; i++)
dump_blob(prop->blob_ids[i]);
printf("\n");
} else {
assert(prop->count_blobs == 0);
}

printf("\t\tvalue:");
if (prop->flags & DRM_MODE_PROP_BLOB)
dump_blob(value);
else
printf(" %"PRIu64"\n", value);

drmModeFreeProperty(prop);
}

void dump_connectors(void)
Expand Down Expand Up @@ -199,17 +279,18 @@ void dump_connectors(void)
printf("%s%d", j > 0 ? ", " : "", connector->encoders[j]);
printf("\n");

if (!connector->count_modes)
continue;

printf(" modes:\n");
printf(" name refresh (Hz) hdisp hss hse htot vdisp "
"vss vse vtot)\n");
for (j = 0; j < connector->count_modes; j++)
dump_mode(&connector->modes[j]);

printf(" props:\n");
dump_props(connector);
if (connector->count_modes) {
printf(" modes:\n");
printf("\tname refresh (Hz) hdisp hss hse htot vdisp "
"vss vse vtot)\n");
for (j = 0; j < connector->count_modes; j++)
dump_mode(&connector->modes[j]);

printf(" props:\n");
for (j = 0; j < connector->count_props; j++)
dump_prop(connector->props[j],
connector->prop_values[j]);
}

drmModeFreeConnector(connector);
}
Expand All @@ -219,7 +300,9 @@ void dump_connectors(void)
void dump_crtcs(void)
{
drmModeCrtc *crtc;
drmModeObjectPropertiesPtr props;
int i;
uint32_t j;

printf("CRTCs:\n");
printf("id\tfb\tpos\tsize\n");
Expand All @@ -238,6 +321,19 @@ void dump_crtcs(void)
crtc->width, crtc->height);
dump_mode(&crtc->mode);

printf(" props:\n");
props = drmModeObjectGetProperties(fd, crtc->crtc_id,
DRM_MODE_OBJECT_CRTC);
if (props) {
for (j = 0; j < props->count_props; j++)
dump_prop(props->props[j],
props->prop_values[j]);
drmModeFreeObjectProperties(props);
} else {
printf("\tcould not get crtc properties: %s\n",
strerror(errno));
}

drmModeFreeCrtc(crtc);
}
printf("\n");
Expand Down Expand Up @@ -270,6 +366,7 @@ void dump_framebuffers(void)

static void dump_planes(void)
{
drmModeObjectPropertiesPtr props;
drmModePlaneRes *plane_resources;
drmModePlane *ovr;
int i, j;
Expand Down Expand Up @@ -304,6 +401,19 @@ static void dump_planes(void)
printf(" %4.4s", (char *)&ovr->formats[j]);
printf("\n");

printf(" props:\n");
props = drmModeObjectGetProperties(fd, ovr->plane_id,
DRM_MODE_OBJECT_PLANE);
if (props) {
for (j = 0; j < props->count_props; j++)
dump_prop(props->props[j],
props->prop_values[j]);
drmModeFreeObjectProperties(props);
} else {
printf("\tcould not get plane properties: %s\n",
strerror(errno));
}

drmModeFreePlane(ovr);
}
printf("\n");
Expand Down Expand Up @@ -995,7 +1105,7 @@ void usage(char *name)

#define dump_resource(res) if (res) dump_##res()

static int page_flipping_supported(int fd)
static int page_flipping_supported(void)
{
/*FIXME: generic ioctl needed? */
return 1;
Expand All @@ -1022,8 +1132,8 @@ int main(int argc, char **argv)
int encoders = 0, connectors = 0, crtcs = 0, planes = 0, framebuffers = 0;
int test_vsync = 0;
char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm" };
char *modeset = NULL;
int i, count = 0, plane_count = 0;
unsigned int i;
int count = 0, plane_count = 0;
struct connector con_args[2];
struct plane plane_args[2] = {0};

Expand All @@ -1050,7 +1160,6 @@ int main(int argc, char **argv)
test_vsync = 1;
break;
case 's':
modeset = strdup(optarg);
con_args[count].crtc = -1;
if (sscanf(optarg, "%d:%64s",
&con_args[count].id,
Expand Down Expand Up @@ -1096,7 +1205,7 @@ int main(int argc, char **argv)
}
}

if (test_vsync && !page_flipping_supported(fd)) {
if (test_vsync && !page_flipping_supported()) {
fprintf(stderr, "page flipping not supported by drm.\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/vbltest/vbltest.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void usage(char *name)
int main(int argc, char **argv)
{
int i, c, fd, ret;
char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx" };
char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm" };
drmVBlank vbl;
drmEventContext evctx;
struct vbl_info handler_info;
Expand Down
Loading