return NULL;
}
-static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int count)
+static unsigned int set_mode(struct device *dev, struct pipe_arg **pipe_args, unsigned int count)
{
unsigned int i, j;
int ret, x = 0;
int preferred = count == 0;
+ struct pipe_arg *pipes;
- for (i = 0; i < count; i++) {
- struct pipe_arg *pipe = &pipes[i];
-
- ret = pipe_resolve_connectors(dev, pipe);
- if (ret < 0)
- return;
-
- ret = pipe_find_crtc_and_mode(dev, pipe);
- if (ret < 0)
- continue;
- }
if (preferred) {
- struct pipe_arg *pipe_args;
-
- count = pipe_find_preferred(dev, &pipe_args);
+ count = pipe_find_preferred(dev, pipe_args);
if (!count) {
fprintf(stderr, "can't find any preferred connector/mode.\n");
- return;
+ return 0;
+ }
+
+ pipes = *pipe_args;
+ } else {
+ pipes = *pipe_args;
+
+ for (i = 0; i < count; i++) {
+ struct pipe_arg *pipe = &pipes[i];
+
+ ret = pipe_resolve_connectors(dev, pipe);
+ if (ret < 0)
+ return 0;
+
+ ret = pipe_find_crtc_and_mode(dev, pipe);
+ if (ret < 0)
+ continue;
}
- pipes = pipe_args;
}
if (!dev->use_atomic) {
if (bo_fb_create(dev->fd, pipes[0].fourcc, dev->mode.width, dev->mode.height,
primary_fill, &dev->mode.bo, &dev->mode.fb_id))
- return;
+ return 0;
}
for (i = 0; i < count; i++) {
if (ret) {
fprintf(stderr, "failed to set mode: %s\n", strerror(errno));
- return;
+ return 0;
}
set_gamma(dev, pipe->crtc_id, pipe->fourcc);
}
}
}
+
+ return count;
}
static void writeback_config(struct device *dev, struct pipe_arg *pipes, unsigned int count)
if (!args)
encoders = connectors = crtcs = planes = framebuffers = 1;
- if (test_vsync && !count) {
- fprintf(stderr, "page flipping requires at least one -s option.\n");
+ if (test_vsync && !count && !set_preferred) {
+ fprintf(stderr, "page flipping requires at least one -s or -r option.\n");
return -1;
}
if (set_preferred && count) {
}
if (set_preferred || count)
- set_mode(&dev, pipe_args, count);
+ count = set_mode(&dev, &pipe_args, count);
if (dump_path) {
if (!pipe_has_writeback_connector(&dev, pipe_args, count)) {
}
if (set_preferred || count)
- set_mode(&dev, pipe_args, count);
+ count = set_mode(&dev, &pipe_args, count);
if (plane_count)
set_planes(&dev, plane_args, plane_count);