Commit 5d0e9dec authored by Ilia Mirkin's avatar Ilia Mirkin

modetest: add the ability to specify fill patterns on the commandline

Instead of hacking the binary every time, we can now specify directly.
Signed-off-by: default avatarIlia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
parent bfc469f2
......@@ -67,6 +67,9 @@
#include "buffers.h"
#include "cursor.h"
static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE;
static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES;
struct crtc {
drmModeCrtc *crtc;
drmModeObjectProperties *props;
......@@ -1259,7 +1262,7 @@ static int set_plane(struct device *dev, struct plane_arg *p)
p->w, p->h, p->format_str, plane_id);
plane_bo = bo_create(dev->fd, p->fourcc, p->w, p->h, handles,
pitches, offsets, UTIL_PATTERN_TILES);
pitches, offsets, secondary_fill);
if (plane_bo == NULL)
return -1;
......@@ -1300,12 +1303,12 @@ static int set_plane(struct device *dev, struct plane_arg *p)
static void atomic_set_planes(struct device *dev, struct plane_arg *p,
unsigned int count, bool update)
{
unsigned int i, pattern = UTIL_PATTERN_SMPTE;
unsigned int i, pattern = primary_fill;
/* set up planes */
for (i = 0; i < count; i++) {
if (i > 0)
pattern = UTIL_PATTERN_TILES;
pattern = secondary_fill;
else
set_gamma(dev, p[i].crtc_id, p[i].fourcc);
......@@ -1450,7 +1453,7 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width,
dev->mode.height, handles, pitches, offsets,
UTIL_PATTERN_SMPTE);
primary_fill);
if (bo == NULL)
return;
......@@ -1794,6 +1797,18 @@ static int parse_property(struct property_arg *p, const char *arg)
return 0;
}
static void parse_fill_patterns(char *arg)
{
char *fill = strtok(arg, ",");
if (!fill)
return;
primary_fill = util_pattern_enum(fill);
fill = strtok(NULL, ",");
if (!fill)
return;
secondary_fill = util_pattern_enum(fill);
}
static void usage(char *name)
{
fprintf(stderr, "usage: %s [-acDdefMPpsCvw]\n", name);
......@@ -1811,6 +1826,7 @@ static void usage(char *name)
fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
fprintf(stderr, "\t-a \tuse atomic API\n");
fprintf(stderr, "\t-F pattern1,pattern2\tspecify fill patterns\n");
fprintf(stderr, "\n Generic options:\n\n");
fprintf(stderr, "\t-d\tdrop master after mode set\n");
......@@ -1874,7 +1890,7 @@ static int pipe_resolve_connectors(struct device *dev, struct pipe_arg *pipe)
return 0;
}
static char optstr[] = "acdD:efM:P:ps:Cvw:";
static char optstr[] = "acdD:efF:M:P:ps:Cvw:";
int main(int argc, char **argv)
{
......@@ -1923,6 +1939,9 @@ int main(int argc, char **argv)
case 'f':
framebuffers = 1;
break;
case 'F':
parse_fill_patterns(optarg);
break;
case 'M':
module = optarg;
/* Preserve the default behaviour of dumping all information. */
......
......@@ -35,6 +35,7 @@
#include <math.h>
#endif
#include "common.h"
#include "format.h"
#include "pattern.h"
......@@ -1261,3 +1262,22 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern,
break;
}
}
static const char *pattern_names[] = {
[UTIL_PATTERN_TILES] = "tiles",
[UTIL_PATTERN_SMPTE] = "smpte",
[UTIL_PATTERN_PLAIN] = "plain",
[UTIL_PATTERN_GRADIENT] = "gradient",
};
enum util_fill_pattern util_pattern_enum(const char *name)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(pattern_names); i++)
if (!strcmp(pattern_names[i], name))
return (enum util_fill_pattern)i;
printf("Error: unsupported test pattern %s.\n", name);
return UTIL_PATTERN_SMPTE;
}
......@@ -41,4 +41,6 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern,
void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut);
enum util_fill_pattern util_pattern_enum(const char *name);
#endif /* UTIL_PATTERN_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment