diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 165b9529..81ca77ff 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -114,7 +114,8 @@ struct bo * bo_create(int fd, unsigned int format, unsigned int width, unsigned int height, unsigned int handles[4], unsigned int pitches[4], - unsigned int offsets[4], enum util_fill_pattern pattern) + unsigned int offsets[4], enum util_fill_pattern pattern, + unsigned long seed) { unsigned int virtual_height, xsub, ysub; struct bo *bo; @@ -386,7 +387,7 @@ bo_create(int fd, unsigned int format, break; } - util_fill_pattern(format, pattern, planes, width, height, pitches[0]); + util_fill_pattern(format, pattern, planes, width, height, pitches[0], seed); bo_unmap(bo); return bo; diff --git a/tests/modetest/buffers.h b/tests/modetest/buffers.h index cbd54e9e..d7db67bf 100644 --- a/tests/modetest/buffers.h +++ b/tests/modetest/buffers.h @@ -34,7 +34,8 @@ struct bo; struct bo *bo_create(int fd, unsigned int format, unsigned int width, unsigned int height, unsigned int handles[4], unsigned int pitches[4], - unsigned int offsets[4], enum util_fill_pattern pattern); + unsigned int offsets[4], enum util_fill_pattern pattern, + unsigned long seed); void bo_destroy(struct bo *bo); void bo_dump(struct bo *bo, const char *filename); diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index d9e761e6..24c0e2dc 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -70,6 +70,7 @@ static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE; static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES; +static unsigned long pattern_seed = 0; static drmModeModeInfo user_mode; struct crtc { @@ -1199,7 +1200,7 @@ bo_fb_create(int fd, unsigned int fourcc, const uint32_t w, const uint32_t h, struct bo *bo; unsigned int fb_id; - bo = bo_create(fd, fourcc, w, h, handles, pitches, offsets, pat); + bo = bo_create(fd, fourcc, w, h, handles, pitches, offsets, pat, pattern_seed); if (bo == NULL) return -1; @@ -1857,7 +1858,7 @@ static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned int * translucent alpha */ bo = bo_create(dev->fd, DRM_FORMAT_ARGB8888, cw, ch, handles, pitches, - offsets, UTIL_PATTERN_PLAIN); + offsets, UTIL_PATTERN_PLAIN, pattern_seed); if (bo == NULL) return; @@ -2126,6 +2127,16 @@ static void parse_fill_patterns(char *arg) secondary_fill = util_pattern_enum(fill); } +static void parse_seed(const char *arg) +{ + unsigned long seed; + char *rest; + + seed = strtoul(arg, &rest, 10); + if (arg != rest) + pattern_seed = seed; +} + static void usage(char *name) { fprintf(stderr, "usage: %s [-acDdefMoPpsCvrw]\n", name); @@ -2149,6 +2160,7 @@ static void usage(char *name) fprintf(stderr, "\t-w ::\tset property, see 'property'\n"); fprintf(stderr, "\t-a \tuse atomic API\n"); fprintf(stderr, "\t-F pattern1,pattern2\tspecify fill patterns\n"); + fprintf(stderr, "\t-S \tspecify seed of noise patterns\n"); fprintf(stderr, "\t-o \t Dump writeback output buffer to file\n"); fprintf(stderr, "\n Generic options:\n\n"); @@ -2179,7 +2191,7 @@ static void usage(char *name) exit(0); } -static char optstr[] = "acdD:efF:M:P:ps:Cvrw:o:"; +static char optstr[] = "acdD:efF:M:P:ps:Cvrw:o:S:"; int main(int argc, char **argv) { @@ -2276,6 +2288,9 @@ int main(int argc, char **argv) count++; break; + case 'S': + parse_seed(optarg); + break; case 'C': test_cursor = 1; break; diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 7c78c81b..30284dc3 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -2136,13 +2137,14 @@ static void fill_simple_patterns(const struct util_format_info *info, * @width: Width in pixels * @height: Height in pixels * @stride: Line stride (pitch) in bytes + * @seed: Seed for noise patterns if zero a default time based seed will be used * * Fill the buffers with the test pattern specified by the pattern parameter. * Supported formats vary depending on the selected pattern. */ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, void *planes[3], unsigned int width, - unsigned int height, unsigned int stride) + unsigned int height, unsigned int stride, unsigned long seed) { const struct util_format_info *info; @@ -2150,6 +2152,18 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, if (info == NULL) return; + switch (pattern) { + case UTIL_PATTERN_NOISE: + case UTIL_PATTERN_NOISE_COLOR: + if (!seed) + seed = time(NULL); + srand(seed); + printf("Seed used for noise patterns %lu\n", seed); + break; + default: + break; + } + switch (pattern) { case UTIL_PATTERN_TILES: return fill_tiles(info, planes, width, height, stride); diff --git a/tests/util/pattern.h b/tests/util/pattern.h index 13fd8dc8..064e5a99 100644 --- a/tests/util/pattern.h +++ b/tests/util/pattern.h @@ -40,7 +40,7 @@ enum util_fill_pattern { void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, void *planes[3], unsigned int width, - unsigned int height, unsigned int stride); + unsigned int height, unsigned int stride, unsigned long seed); void util_smpte_fill_lut(unsigned int ncolors, struct drm_color_lut *lut);