index 36bdfffb093cf9bbd65cf0e1097c7d86195b4bbb..dc84cf32bda1ad68d67174c595f15a7a1d4c027c 100644 (file)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#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; \
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,
}
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);
+ if (!blob)
+ return;
+
+ 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);
- 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);
+ 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);
+ }
+
+ 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)
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);
}
void dump_crtcs(void)
{
drmModeCrtc *crtc;
+ drmModeObjectPropertiesPtr props;
int i;
+ uint32_t j;
printf("CRTCs:\n");
printf("id\tfb\tpos\tsize\n");
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");
static void dump_planes(void)
{
+ drmModeObjectPropertiesPtr props;
drmModePlaneRes *plane_resources;
drmModePlane *ovr;
- int i, j;
+ unsigned int i, j;
plane_resources = drmModeGetPlaneResources(fd);
if (!plane_resources) {
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");
+ drmModeFreePlaneResources(plane_resources);
return;
}
}
}
+static void
+fill1555(unsigned char *virtual, int n, int width, int height, int stride)
+{
+ int i, j;
+ /* paint the buffer with colored tiles */
+ for (j = 0; j < height; j++) {
+ uint16_t *ptr = (uint16_t*)((char*)virtual + j * stride);
+ for (i = 0; i < width; i++) {
+ div_t d = div(n+i+j, width);
+ uint32_t rgb = 0x00130502 * (d.quot >> 6) + 0x000a1120 * (d.rem >> 6);
+ unsigned char *rgbp = (unsigned char *)&rgb;
+
+ *(ptr++) = 0x8000 |
+ (rgbp[RED] >> 3) << 10 |
+ (rgbp[GREEN] >> 3) << 5 |
+ (rgbp[BLUE] >> 3);
+ }
+ }
+}
+
static int
set_plane(struct kms_driver *kms, struct connector *c, struct plane *p)
{
uint32_t plane_id = 0;
struct kms_bo *plane_bo;
uint32_t plane_flags = 0, format;
- int i, ret, crtc_x, crtc_y, crtc_w, crtc_h;
+ int ret, crtc_x, crtc_y, crtc_w, crtc_h;
+ unsigned int i;
/* find an unused plane which can be connected to our crtc */
plane_resources = drmModeGetPlaneResources(fd);
kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[1]);
pitches[2] = p->w / 2;
offsets[2] = offsets[1] + (p->w * p->h) / 4;
- kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[1]);
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[2]);
fill420(virtual, virtual+offsets[1], virtual+offsets[2],
1, 0, p->w, p->h, pitches[0]);
format = DRM_FORMAT_YVU420;
+ } else if (!strcmp(p->format_str, "XR15")) {
+ pitches[0] = p->w * 2;
+ offsets[0] = 0;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]);
+
+ fill1555(virtual, 0, p->w, p->h, pitches[0]);
+
+ format = DRM_FORMAT_XRGB1555;
+ } else if (!strcmp(p->format_str, "AR15")) {
+ pitches[0] = p->w * 2;
+ offsets[0] = 0;
+ kms_bo_get_prop(plane_bo, KMS_HANDLE, &handles[0]);
+
+ fill1555(virtual, 0, p->w, p->h, pitches[0]);
+
+ format = DRM_FORMAT_ARGB1555;
} else {
fprintf(stderr, "Unknown format: %s\n", p->format_str);
return -1;
#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;
int c;
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;
+ char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos" };
+ unsigned int i;
+ int count = 0, plane_count = 0;
struct connector con_args[2];
struct plane plane_args[2] = {0};
test_vsync = 1;
break;
case 's':
- modeset = strdup(optarg);
con_args[count].crtc = -1;
if (sscanf(optarg, "%d:%64s",
&con_args[count].id,
}
}
- if (test_vsync && !page_flipping_supported(fd)) {
+ if (test_vsync && !page_flipping_supported()) {
fprintf(stderr, "page flipping not supported by drm.\n");
return -1;
}