aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKristian H. Kristensen2017-09-28 18:02:09 -0500
committerKristian H. Kristensen2017-10-18 14:32:40 -0500
commit511c71c868a7b0fac23e1387290554fee1a85434 (patch)
tree3518563fc0f4fd38d7ffd041d24c8e1a6685cfeb /tests
parent290d29d9794813a2fe0578dbb905ad09bc810516 (diff)
downloadexternal-libdrm-511c71c868a7b0fac23e1387290554fee1a85434.tar.gz
external-libdrm-511c71c868a7b0fac23e1387290554fee1a85434.tar.xz
external-libdrm-511c71c868a7b0fac23e1387290554fee1a85434.zip
modetest: Decode IN_FORMATS plane blob property
This teaches modetest about the new IN_FORMATS blob and decodes the blob to show supported formats and modifiers. Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/modetest/modetest.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index b8891ff5..8ad4766f 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -251,6 +251,89 @@ static void dump_blob(struct device *dev, uint32_t blob_id)
251 drmModeFreePropertyBlob(blob); 251 drmModeFreePropertyBlob(blob);
252} 252}
253 253
254static const char *modifier_to_string(uint64_t modifier)
255{
256 switch (modifier) {
257 case DRM_FORMAT_MOD_INVALID:
258 return "INVALID";
259 case DRM_FORMAT_MOD_LINEAR:
260 return "LINEAR";
261 case I915_FORMAT_MOD_X_TILED:
262 return "X_TILED";
263 case I915_FORMAT_MOD_Y_TILED:
264 return "Y_TILED";
265 case I915_FORMAT_MOD_Yf_TILED:
266 return "Yf_TILED";
267 case I915_FORMAT_MOD_Y_TILED_CCS:
268 return "Y_TILED_CCS";
269 case I915_FORMAT_MOD_Yf_TILED_CCS:
270 return "Yf_TILED_CCS";
271 case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE:
272 return "SAMSUNG_64_32_TILE";
273 case DRM_FORMAT_MOD_VIVANTE_TILED:
274 return "VIVANTE_TILED";
275 case DRM_FORMAT_MOD_VIVANTE_SUPER_TILED:
276 return "VIVANTE_SUPER_TILED";
277 case DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED:
278 return "VIVANTE_SPLIT_TILED";
279 case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED:
280 return "VIVANTE_SPLIT_SUPER_TILED";
281 case NV_FORMAT_MOD_TEGRA_TILED:
282 return "MOD_TEGRA_TILED";
283 case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(0):
284 return "MOD_TEGRA_16BX2_BLOCK(0)";
285 case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(1):
286 return "MOD_TEGRA_16BX2_BLOCK(1)";
287 case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(2):
288 return "MOD_TEGRA_16BX2_BLOCK(2)";
289 case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(3):
290 return "MOD_TEGRA_16BX2_BLOCK(3)";
291 case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(4):
292 return "MOD_TEGRA_16BX2_BLOCK(4)";
293 case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(5):
294 return "MOD_TEGRA_16BX2_BLOCK(5)";
295 case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
296 return "MOD_BROADCOM_VC4_T_TILED";
297 default:
298 return "(UNKNOWN MODIFIER)";
299 }
300}
301
302static void dump_in_formats(struct device *dev, uint32_t blob_id)
303{
304 uint32_t i, j;
305 drmModePropertyBlobPtr blob;
306 struct drm_format_modifier_blob *header;
307 uint32_t *formats;
308 struct drm_format_modifier *modifiers;
309
310 printf("\t\tin_formats blob decoded:\n");
311 blob = drmModeGetPropertyBlob(dev->fd, blob_id);
312 if (!blob) {
313 printf("\n");
314 return;
315 }
316
317 header = blob->data;
318 formats = (uint32_t *) ((char *) header + header->formats_offset);
319 modifiers = (struct drm_format_modifier *)
320 ((char *) header + header->modifiers_offset);
321
322 for (i = 0; i < header->count_formats; i++) {
323 printf("\t\t\t");
324 dump_fourcc(formats[i]);
325 printf(": ");
326 for (j = 0; j < header->count_modifiers; j++) {
327 uint64_t mask = 1ULL << i;
328 if (modifiers[j].formats & mask)
329 printf(" %s", modifier_to_string(modifiers[j].modifier));
330 }
331 printf("\n");
332 }
333
334 drmModeFreePropertyBlob(blob);
335}
336
254static void dump_prop(struct device *dev, drmModePropertyPtr prop, 337static void dump_prop(struct device *dev, drmModePropertyPtr prop,
255 uint32_t prop_id, uint64_t value) 338 uint32_t prop_id, uint64_t value)
256{ 339{
@@ -328,6 +411,9 @@ static void dump_prop(struct device *dev, drmModePropertyPtr prop,
328 printf(" %"PRId64"\n", value); 411 printf(" %"PRId64"\n", value);
329 else 412 else
330 printf(" %"PRIu64"\n", value); 413 printf(" %"PRIu64"\n", value);
414
415 if (strcmp(prop->name, "IN_FORMATS") == 0)
416 dump_in_formats(dev, value);
331} 417}
332 418
333static void dump_connectors(struct device *dev) 419static void dump_connectors(struct device *dev)