mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 05:50:12 +01:00
modetest: util: add seed argument for noise patterns
Add seed argument for modetest noise patterns. If no seed is provided the current time will be used as seed. The used seed will be printed so the noise pattern can be reproduced. Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
This commit is contained in:
parent
40aeab6fd5
commit
289175512c
5 changed files with 39 additions and 8 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <obj_id>:<prop_name>:<value>\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 <random seed>\tspecify seed of noise patterns\n");
|
||||
fprintf(stderr, "\t-o <desired file path> \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;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <drm_fourcc.h>
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue