summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modetest/modetest.c88
1 files changed, 72 insertions, 16 deletions
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index c1b2a72b..0afd1c8d 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -991,17 +991,53 @@ page_flip_handler(int fd, unsigned int frame,
}
}
+static int plane_create_fb(struct device *dev, struct plane_arg *p)
+{
+ uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */
+ struct kms_bo *plane_bo;
+
+ plane_bo = create_test_buffer(dev->kms, p->fourcc, p->w, p->h, handles,
+ pitches, offsets, PATTERN_TILES);
+ if (plane_bo == NULL)
+ return -1;
+
+ /* just use single plane format for now.. */
+ if (drmModeAddFB2(dev->fd, p->w, p->h, p->fourcc,
+ handles, pitches, offsets, &p->fb_id, 0)) {
+ fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+static int plane_setup_source(struct device *dev, struct plane_arg *p,
+ uint32_t plane_id)
+{
+ int ret;
+
+ ret = drmModeSetSource(dev->fd, p->source_id, plane_id, p->w, p->h,
+ p->fourcc);
+ if (ret < 0) {
+ fprintf(stderr, "failed to set source: %s\n", strerror(errno));
+ return ret;
+ }
+
+ p->fb_id = p->source_id;
+ return 0;
+}
+
static int set_plane(struct device *dev, struct plane_arg *p)
{
drmModePlane *ovr;
- uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */
uint32_t plane_id = 0;
- struct kms_bo *plane_bo;
uint32_t plane_flags = 0;
int crtc_x, crtc_y, crtc_w, crtc_h;
struct crtc *crtc = NULL;
+ struct source *src = NULL;
unsigned int pipe;
unsigned int i;
+ int ret;
/* Find an unused plane which can be connected to our CRTC. Find the
* CRTC index first, then iterate over available planes.
@@ -1019,35 +1055,55 @@ static int set_plane(struct device *dev, struct plane_arg *p)
return -1;
}
+ if (p->source_id) {
+ for (i = 0; i < (unsigned int)dev->resources->source_res->count_sources; i++) {
+ if (p->source_id == dev->resources->source_res->sources[i]) {
+ src = &dev->resources->sources[i];
+ break;
+ }
+ }
+
+ if (!src) {
+ fprintf(stderr, "Source %u not found\n", p->source_id);
+ return -1;
+ }
+ }
+
for (i = 0; i < dev->resources->plane_res->count_planes && !plane_id; i++) {
ovr = dev->resources->planes[i].plane;
if (!ovr)
continue;
- if ((ovr->possible_crtcs & (1 << pipe)) && !ovr->crtc_id)
- plane_id = ovr->plane_id;
+ if (ovr->crtc_id)
+ continue;
+
+ if (!(ovr->possible_crtcs & (1 << pipe)))
+ continue;
+
+ if (src && !(src->source->possible_planes & (1 << i)))
+ continue;
+
+ plane_id = ovr->plane_id;
+ break;
}
if (!plane_id) {
- fprintf(stderr, "no unused plane available for CRTC %u\n",
- crtc->crtc->crtc_id);
+ fprintf(stderr,
+ "no unused plane available for CRTC %u and source %u\n",
+ crtc->crtc->crtc_id, p->source_id);
return -1;
}
fprintf(stderr, "testing %dx%d@%s overlay plane %u\n",
p->w, p->h, p->format_str, plane_id);
- plane_bo = create_test_buffer(dev->kms, p->fourcc, p->w, p->h, handles,
- pitches, offsets, PATTERN_TILES);
- if (plane_bo == NULL)
- return -1;
+ if (p->source_id)
+ ret = plane_setup_source(dev, p, plane_id);
+ else
+ ret = plane_create_fb(dev, p);
- /* just use single plane format for now.. */
- if (drmModeAddFB2(dev->fd, p->w, p->h, p->fourcc,
- handles, pitches, offsets, &p->fb_id, plane_flags)) {
- fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
- return -1;
- }
+ if (ret < 0)
+ return ret;
if (!p->has_position) {
/* Default to the middle of the screen */