summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mode/Makefile11
-rw-r--r--tests/mode/modetest.c10
-rwxr-xr-xtests/mode/test2
-rw-r--r--tests/modedemo/Makefile14
-rw-r--r--tests/modedemo/demo.c119
-rwxr-xr-xtests/modedemo/test1
6 files changed, 151 insertions, 6 deletions
diff --git a/tests/mode/Makefile b/tests/mode/Makefile
index a3d3b49a..7a9c3c24 100644
--- a/tests/mode/Makefile
+++ b/tests/mode/Makefile
@@ -1,11 +1,14 @@
-all: modetest
+all: app
#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
-modetest: modetest.c
- @gcc $(CFLAGS) -o modetest -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c
+app: modetest.c
+ @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c
clean:
- @rm -f modetest
+ @rm -f app
+
+run: app
+ @sudo ./test
diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c
index bd8372dc..c1f291b2 100644
--- a/tests/mode/modetest.c
+++ b/tests/mode/modetest.c
@@ -278,7 +278,15 @@ int testFrameBufferAdd(int fd, drmModeResPtr res)
printf("\tCreating BO\n");
/* TODO */
- ret = 1;
+ ret = drmBOCreate(fd, 800 * 600 * 4, 0, 0,
+ DRM_BO_FLAG_READ |
+ DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_MEM_VRAM |
+ DRM_BO_FLAG_NO_EVICT,
+ DRM_BO_HINT_DONT_FENCE, &bo);
+
+ printf("\tgot %i\n", ret);
if (ret)
goto err;
diff --git a/tests/mode/test b/tests/mode/test
index fa155f4e..f98e3708 100755
--- a/tests/mode/test
+++ b/tests/mode/test
@@ -1 +1 @@
-LD_PRELOAD=../../libdrm/.libs/libdrm.so ./modetest
+LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app
diff --git a/tests/modedemo/Makefile b/tests/modedemo/Makefile
new file mode 100644
index 00000000..467fb11a
--- /dev/null
+++ b/tests/modedemo/Makefile
@@ -0,0 +1,14 @@
+
+all: app
+
+#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
+# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
+
+app: demo.c
+ @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm demo.c
+
+clean:
+ @rm -f app
+
+run: app
+ sudo ./test
diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c
new file mode 100644
index 00000000..ea71fd1d
--- /dev/null
+++ b/tests/modedemo/demo.c
@@ -0,0 +1,119 @@
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "xf86drm.h"
+#include "xf86drmMode.h"
+static struct drm_mode_modeinfo mode = {
+ .name = "Test mode",
+ .clock = 25200,
+ .hdisplay = 640,
+ .hsync_start = 656,
+ .hsync_end = 752,
+ .htotal = 800,
+ .hskew = 0,
+ .vdisplay = 480,
+ .vsync_start = 490,
+ .vsync_end = 492,
+ .vtotal = 525,
+ .vscan = 0,
+ .vrefresh = 60000, /* vertical refresh * 1000 */
+ .flags = 10,
+};
+
+drmModeFBPtr createFB(int fd, drmModeResPtr res);
+int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out);
+drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res);
+
+int main(int argc, char **argv)
+{
+ int fd;
+ const char *driver = "i915"; /* hardcoded for now */
+ drmModeResPtr res;
+ drmModeFBPtr framebuffer;
+ int numOutputs;
+ drmModeOutputPtr out[8];
+ drmModeCrtcPtr crtc;
+
+ printf("Starting test\n");
+
+ fd = drmOpen(driver, NULL);
+
+ if (fd < 0) {
+ printf("Failed to open the card fb\n");
+ return 1;
+ }
+
+ res = drmModeGetResources(fd);
+ if (res == 0) {
+ printf("Failed to get resources from card\n");
+ drmClose(fd);
+ return 1;
+ }
+
+ framebuffer = createFB(fd, res);
+ if (framebuffer == NULL) {
+ printf("Failed to create framebuffer\n");
+ return 1;
+ }
+
+ numOutputs = findConnectedOutputs(fd, res, out);
+ if (numOutputs < 1) {
+ printf("Failed to find connected outputs\n");
+ return 1;
+ }
+
+ crtc = findFreeCrtc(fd, res);
+ if (numOutputs < 1) {
+ printf("Couldn't find a free crtc\n");
+ return 1;
+ }
+
+
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[0]->output_id, 1, &mode);
+ sleep(2);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 500, &out[0]->output_id, 1, &mode);
+ sleep(2);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 500, 0, &out[0]->output_id, 1, &mode);
+ sleep(2);
+ drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 500, 500, &out[0]->output_id, 1, &mode);
+
+ drmModeFreeResources(res);
+ printf("Ok\n");
+
+ return 0;
+}
+
+drmModeFBPtr createFB(int fd, drmModeResPtr res)
+{
+ /* Haveing problems getting drmBOCreate to work with me. */
+ return drmModeGetFB(fd, res->fbs[1]);
+}
+
+int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out)
+{
+ int count = 0;
+ int i;
+
+ drmModeOutputPtr output;
+
+ for (i = 0; i < res->count_outputs; i++) {
+ output = drmModeGetOutput(fd, res->outputs[i]);
+
+ if (!output || output->connection != DRM_MODE_CONNECTED)
+ continue;
+
+ out[count++] = output;
+ }
+
+ return count;
+}
+
+drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res)
+{
+ return drmModeGetCrtc(fd, res->crtcs[0]);
+}
diff --git a/tests/modedemo/test b/tests/modedemo/test
new file mode 100755
index 00000000..f98e3708
--- /dev/null
+++ b/tests/modedemo/test
@@ -0,0 +1 @@
+LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app