aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modetest/modetest.c')
-rw-r--r--tests/modetest/modetest.c110
1 files changed, 102 insertions, 8 deletions
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index cd911193..62957d84 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -38,10 +38,6 @@
38 * the mode has been programmed, along with possible test patterns. 38 * the mode has been programmed, along with possible test patterns.
39 */ 39 */
40 40
41#ifdef HAVE_CONFIG_H
42#include "config.h"
43#endif
44
45#include <assert.h> 41#include <assert.h>
46#include <ctype.h> 42#include <ctype.h>
47#include <stdbool.h> 43#include <stdbool.h>
@@ -174,6 +170,15 @@ static const char *mode_flag_names[] = {
174 170
175static bit_name_fn(mode_flag) 171static bit_name_fn(mode_flag)
176 172
173static void dump_fourcc(uint32_t fourcc)
174{
175 printf(" %c%c%c%c",
176 fourcc,
177 fourcc >> 8,
178 fourcc >> 16,
179 fourcc >> 24);
180}
181
177static void dump_encoders(struct device *dev) 182static void dump_encoders(struct device *dev)
178{ 183{
179 drmModeEncoder *encoder; 184 drmModeEncoder *encoder;
@@ -242,6 +247,89 @@ static void dump_blob(struct device *dev, uint32_t blob_id)
242 drmModeFreePropertyBlob(blob); 247 drmModeFreePropertyBlob(blob);
243} 248}
244 249
250static const char *modifier_to_string(uint64_t modifier)
251{
252 switch (modifier) {
253 case DRM_FORMAT_MOD_INVALID:
254 return "INVALID";
255 case DRM_FORMAT_MOD_LINEAR:
256 return "LINEAR";
257 case I915_FORMAT_MOD_X_TILED:
258 return "X_TILED";
259 case I915_FORMAT_MOD_Y_TILED:
260 return "Y_TILED";
261 case I915_FORMAT_MOD_Yf_TILED:
262 return "Yf_TILED";
263 case I915_FORMAT_MOD_Y_TILED_CCS:
264 return "Y_TILED_CCS";
265 case I915_FORMAT_MOD_Yf_TILED_CCS:
266 return "Yf_TILED_CCS";
267 case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE:
268 return "SAMSUNG_64_32_TILE";
269 case DRM_FORMAT_MOD_VIVANTE_TILED:
270 return "VIVANTE_TILED";
271 case DRM_FORMAT_MOD_VIVANTE_SUPER_TILED:
272 return "VIVANTE_SUPER_TILED";
273 case DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED:
274 return "VIVANTE_SPLIT_TILED";
275 case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED:
276 return "VIVANTE_SPLIT_SUPER_TILED";
277 case DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED:
278 return "NVIDIA_TEGRA_TILED";
279 case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0):
280 return "NVIDIA_16BX2_BLOCK(0)";
281 case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1):
282 return "NVIDIA_16BX2_BLOCK(1)";
283 case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2):
284 return "NVIDIA_16BX2_BLOCK(2)";
285 case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3):
286 return "NVIDIA_16BX2_BLOCK(3)";
287 case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4):
288 return "NVIDIA_16BX2_BLOCK(4)";
289 case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5):
290 return "NVIDIA_16BX2_BLOCK(5)";
291 case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
292 return "MOD_BROADCOM_VC4_T_TILED";
293 default:
294 return "(UNKNOWN MODIFIER)";
295 }
296}
297
298static void dump_in_formats(struct device *dev, uint32_t blob_id)
299{
300 uint32_t i, j;
301 drmModePropertyBlobPtr blob;
302 struct drm_format_modifier_blob *header;
303 uint32_t *formats;
304 struct drm_format_modifier *modifiers;
305
306 printf("\t\tin_formats blob decoded:\n");
307 blob = drmModeGetPropertyBlob(dev->fd, blob_id);
308 if (!blob) {
309 printf("\n");
310 return;
311 }
312
313 header = blob->data;
314 formats = (uint32_t *) ((char *) header + header->formats_offset);
315 modifiers = (struct drm_format_modifier *)
316 ((char *) header + header->modifiers_offset);
317
318 for (i = 0; i < header->count_formats; i++) {
319 printf("\t\t\t");
320 dump_fourcc(formats[i]);
321 printf(": ");
322 for (j = 0; j < header->count_modifiers; j++) {
323 uint64_t mask = 1ULL << i;
324 if (modifiers[j].formats & mask)
325 printf(" %s", modifier_to_string(modifiers[j].modifier));
326 }
327 printf("\n");
328 }
329
330 drmModeFreePropertyBlob(blob);
331}
332
245static void dump_prop(struct device *dev, drmModePropertyPtr prop, 333static void dump_prop(struct device *dev, drmModePropertyPtr prop,
246 uint32_t prop_id, uint64_t value) 334 uint32_t prop_id, uint64_t value)
247{ 335{
@@ -319,6 +407,9 @@ static void dump_prop(struct device *dev, drmModePropertyPtr prop,
319 printf(" %"PRId64"\n", value); 407 printf(" %"PRId64"\n", value);
320 else 408 else
321 printf(" %"PRIu64"\n", value); 409 printf(" %"PRIu64"\n", value);
410
411 if (strcmp(prop->name, "IN_FORMATS") == 0)
412 dump_in_formats(dev, value);
322} 413}
323 414
324static void dump_connectors(struct device *dev) 415static void dump_connectors(struct device *dev)
@@ -443,7 +534,7 @@ static void dump_planes(struct device *dev)
443 534
444 printf(" formats:"); 535 printf(" formats:");
445 for (j = 0; j < ovr->count_formats; j++) 536 for (j = 0; j < ovr->count_formats; j++)
446 printf(" %4.4s", (char *)&ovr->formats[j]); 537 dump_fourcc(ovr->formats[j]);
447 printf("\n"); 538 printf("\n");
448 539
449 if (plane->props) { 540 if (plane->props) {
@@ -524,7 +615,6 @@ static struct resources *get_resources(struct device *dev)
524 return NULL; 615 return NULL;
525 616
526 drmSetClientCap(dev->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); 617 drmSetClientCap(dev->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
527 drmSetClientCap(dev->fd, DRM_CLIENT_CAP_ATOMIC, 1);
528 618
529 res->res = drmModeGetResources(dev->fd); 619 res->res = drmModeGetResources(dev->fd);
530 if (!res->res) { 620 if (!res->res) {
@@ -562,10 +652,13 @@ static struct resources *get_resources(struct device *dev)
562 for (i = 0; i < res->res->count_connectors; i++) { 652 for (i = 0; i < res->res->count_connectors; i++) {
563 struct connector *connector = &res->connectors[i]; 653 struct connector *connector = &res->connectors[i];
564 drmModeConnector *conn = connector->connector; 654 drmModeConnector *conn = connector->connector;
655 int num;
565 656
566 asprintf(&connector->name, "%s-%u", 657 num = asprintf(&connector->name, "%s-%u",
567 util_lookup_connector_type_name(conn->connector_type), 658 util_lookup_connector_type_name(conn->connector_type),
568 conn->connector_type_id); 659 conn->connector_type_id);
660 if (num < 0)
661 goto error;
569 } 662 }
570 663
571#define get_properties(_res, __res, type, Type) \ 664#define get_properties(_res, __res, type, Type) \
@@ -997,7 +1090,8 @@ static int set_plane(struct device *dev, struct plane_arg *p)
997 if (!format_support(ovr, p->fourcc)) 1090 if (!format_support(ovr, p->fourcc))
998 continue; 1091 continue;
999 1092
1000 if ((ovr->possible_crtcs & (1 << pipe)) && !ovr->crtc_id) { 1093 if ((ovr->possible_crtcs & (1 << pipe)) &&
1094 (ovr->crtc_id == 0 || ovr->crtc_id == p->crtc_id)) {
1001 plane_id = ovr->plane_id; 1095 plane_id = ovr->plane_id;
1002 break; 1096 break;
1003 } 1097 }