aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-29 12:52:03 +0100
committerScott Anderson <scott@anderso.nz>2020-01-13 16:51:52 +1300
commit1e7c87d6e56cc2a16f4cb39abb0451634ee9cc08 (patch)
treeb6129b8c0b6e9091417e7b70ea4fae53fcc59d85
parent7cabf04ace646af036d47081d9260d1d74295cb1 (diff)
downloadexternal_drm_info-1e7c87d6e56cc2a16f4cb39abb0451634ee9cc08.tar.gz
external_drm_info-1e7c87d6e56cc2a16f4cb39abb0451634ee9cc08.tar.bz2
external_drm_info-1e7c87d6e56cc2a16f4cb39abb0451634ee9cc08.zip
Add FB info
Closes: https://github.com/ascent12/drm_info/issues/45
-rw-r--r--json.c33
-rw-r--r--pretty.c29
2 files changed, 61 insertions, 1 deletions
diff --git a/json.c b/json.c
index fac7025..6b0e842 100644
--- a/json.c
+++ b/json.c
@@ -298,6 +298,29 @@ static struct json_object *path_info(int fd, uint32_t blob_id)
return obj;
}
+static struct json_object *fb_info(int fd, uint32_t id)
+{
+ // TODO: use drmModeGetFB2: https://patchwork.freedesktop.org/series/67552/
+ drmModeFB *fb = drmModeGetFB(fd, id);
+ if (!fb) {
+ perror("drmModeGetFB");
+ return NULL;
+ }
+
+ struct json_object *obj = json_object_new_object();
+ json_object_object_add(obj, "id", new_json_object_uint64(fb->fb_id));
+ json_object_object_add(obj, "width", new_json_object_uint64(fb->width));
+ json_object_object_add(obj, "height", new_json_object_uint64(fb->height));
+
+ json_object_object_add(obj, "pitch", new_json_object_uint64(fb->pitch));
+ json_object_object_add(obj, "bpp", new_json_object_uint64(fb->bpp));
+ json_object_object_add(obj, "depth", new_json_object_uint64(fb->depth));
+
+ drmModeFreeFB(fb);
+
+ return obj;
+}
+
static struct json_object *properties_info(int fd, uint32_t id, uint32_t type)
{
@@ -402,7 +425,7 @@ static struct json_object *properties_info(int fd, uint32_t id, uint32_t type)
} else if (strcmp(prop->name, "WRITEBACK_PIXEL_FORMATS") == 0) {
data_obj = writeback_pixel_formats_info(fd, value);
} else if (strcmp(prop->name, "PATH") == 0) {
- data_obj = path_info(fd, props->prop_values[i]);
+ data_obj = path_info(fd, value);
}
break;
case DRM_MODE_PROP_RANGE:
@@ -412,6 +435,14 @@ static struct json_object *properties_info(int fd, uint32_t id, uint32_t type)
data_obj = new_json_object_uint64(value >> 16);
}
break;
+ case DRM_MODE_PROP_OBJECT:
+ if (!value) {
+ break;
+ }
+ if (strcmp(prop->name, "FB_ID") == 0) {
+ data_obj = fb_info(fd, value);
+ }
+ break;
}
json_object_object_add(prop_obj, "data", data_obj);
diff --git a/pretty.c b/pretty.c
index 5070316..6cb42af 100644
--- a/pretty.c
+++ b/pretty.c
@@ -330,6 +330,31 @@ static void print_path(struct json_object *obj, const char *prefix)
printf("%s" L_LAST "%s\n", prefix, json_object_get_string(obj));
}
+static void print_fb(struct json_object *obj, const char *prefix)
+{
+ uint32_t id = get_object_object_uint64(obj, "id");
+ uint32_t width = get_object_object_uint64(obj, "width");
+ uint32_t height = get_object_object_uint64(obj, "height");
+
+ struct json_object *pitch_obj = json_object_object_get(obj, "pitch");
+ struct json_object *bpp_obj = json_object_object_get(obj, "bpp");
+ struct json_object *depth_obj = json_object_object_get(obj, "depth");
+ bool has_legacy = pitch_obj && bpp_obj && depth_obj;
+
+ printf("%s" L_VAL "Object ID: %"PRIu32"\n", prefix, id);
+ printf("%s%sSize: %"PRIu32"x%"PRIu32"\n", prefix,
+ has_legacy ? L_VAL : L_LAST, width, height);
+
+ if (has_legacy) {
+ printf("%s" L_VAL "Pitch: %"PRIu32"\n", prefix,
+ (uint32_t)get_object_uint64(pitch_obj));
+ printf("%s" L_VAL "Bits per pixel: %"PRIu32"\n", prefix,
+ (uint32_t)get_object_uint64(bpp_obj));
+ printf("%s" L_LAST "Depth: %"PRIu32"\n", prefix,
+ (uint32_t)get_object_uint64(depth_obj));
+ }
+}
+
static void print_properties(struct json_object *obj, const char *prefix)
{
printf("%s" L_LAST "Properties\n", prefix);
@@ -462,6 +487,10 @@ static void print_properties(struct json_object *obj, const char *prefix)
case DRM_MODE_PROP_OBJECT:;
uint32_t obj_type = get_object_uint64(spec_obj);
printf("object %s = %"PRIu64"\n", obj_str(obj_type), raw_val);
+ if (!data_obj)
+ break;
+ if (strcmp(prop_name, "FB_ID") == 0)
+ print_fb(data_obj, sub_prefix);
break;
case DRM_MODE_PROP_SIGNED_RANGE:;
int64_t smin =