aboutsummaryrefslogtreecommitdiff
path: root/tests/modedemo/demo.c
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@tungstengraphics.com>2008-01-28 03:12:29 +0100
committerJakob Bornecrantz <jakob@tungstengraphics.com>2008-01-28 03:14:56 +0100
commita2254c5a9670a3e865f0eb5acd46e905c9b146ce (patch)
tree080e144b12585dc3dd4c7e3cae63bb3dbe004486 /tests/modedemo/demo.c
parent98361cf28c62530e34758b27aa1eea805269e0e5 (diff)
Added cursor support
Diffstat (limited to 'tests/modedemo/demo.c')
-rw-r--r--tests/modedemo/demo.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c
index 594d60db..1efeb272 100644
--- a/tests/modedemo/demo.c
+++ b/tests/modedemo/demo.c
@@ -34,7 +34,9 @@ static struct drm_mode_modeinfo mode = {
drmModeFBPtr createFB(int fd, drmModeResPtr res);
int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out);
drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res);
+void testCursor(int fd, uint32_t crtc);
void prettyColors(int fd, unsigned int handle);
+void prettyCursor(int fd, unsigned int handle);
int main(int argc, char **argv)
{
@@ -98,6 +100,11 @@ int main(int argc, char **argv)
drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[0]->output_id, 1, &mode);
sleep(2);
+ printf("0 0\n");
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 1, 1, &out[0]->output_id, 1, &mode);
+
+ testCursor(fd, crtc->crtc_id);
+
/* turn the crtc off just in case */
drmModeSetCrtc(fd, crtc->crtc_id, 0, 0, 0, 0, 0, 0);
@@ -166,7 +173,7 @@ int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out)
drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res)
{
- return drmModeGetCrtc(fd, res->crtcs[0]);
+ return drmModeGetCrtc(fd, res->crtcs[1]);
}
void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr)
@@ -200,3 +207,41 @@ void prettyColors(int fd, unsigned int handle)
drmBOUnmap(fd, &bo);
}
+
+void testCursor(int fd, uint32_t crtc)
+{
+ drmBO bo;
+ int ret;
+ ret = drmBOCreate(fd, 64 * 64 * 4, 0, 0,
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_MEM_VRAM |
+ DRM_BO_FLAG_NO_EVICT,
+ DRM_BO_HINT_DONT_FENCE, &bo);
+
+ prettyCursor(fd, bo.handle);
+
+ printf("set cursor\n");
+ drmModeSetCursor(fd, crtc, &bo, 64, 64);
+ printf("move cursor 0, 0\n");
+ drmModeMoveCursor(fd, crtc, 0, 0);
+ sleep(2);
+ printf("move cursor 40, 40\n");
+ drmModeMoveCursor(fd, crtc, 40, 40);
+ sleep(2);
+}
+
+void prettyCursor(int fd, unsigned int handle)
+{
+ drmBO bo;
+ unsigned int *ptr;
+ int i;
+
+ drmBOReference(fd, handle, &bo);
+ drmBOMap(fd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr);
+
+ for (i = 0; i < (64 * 64); i++)
+ ptr[i] = 0xFFFF00FF;
+
+ drmBOUnmap(fd, &bo);
+}