summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Zavin <rebecca@android.com>2009-07-06 12:24:47 -0700
committerDima Zavin <dima@android.com>2009-07-06 12:26:53 -0700
commit9a8ffbeff88c7b09cc9a86191c7a7fd665ddd980 (patch)
tree5cbefa93d56f88728136959559f608f1483aeaea
parent96ea075eec0bde61223d19065e7f31d80432fe5b (diff)
downloadextras-9a8ffbeff88c7b09cc9a86191c7a7fd665ddd980.tar.gz
tests: Add a simple MDP test.
Signed-off-by: Dima Zavin <dima@android.com>
-rw-r--r--tests/framebuffer/Android.mk9
-rw-r--r--tests/framebuffer/mdp_test.c143
2 files changed, 152 insertions, 0 deletions
diff --git a/tests/framebuffer/Android.mk b/tests/framebuffer/Android.mk
index 4f789b9e..2c048573 100644
--- a/tests/framebuffer/Android.mk
+++ b/tests/framebuffer/Android.mk
@@ -30,4 +30,13 @@ LOCAL_MODULE_TAGS := optional
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_STATIC_LIBRARIES := libc
include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := mdp_test.c
+LOCAL_MODULE = test-mdp
+LOCAL_MODULE_TAGS := optional
+LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_STATIC_LIBRARIES := libc
+include $(BUILD_EXECUTABLE)
+
endif # sim
diff --git a/tests/framebuffer/mdp_test.c b/tests/framebuffer/mdp_test.c
new file mode 100644
index 00000000..7307eb91
--- /dev/null
+++ b/tests/framebuffer/mdp_test.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+
+#include <linux/fb.h>
+#include <linux/msm_mdp.h>
+
+static struct fb_var_screeninfo vi;
+
+static int get_framebuffer(int *fd, char **fb, int *width, int *height)
+{
+ struct fb_fix_screeninfo fi;
+ void *bits;
+
+ *fd = open("/dev/graphics/fb0", O_RDWR);
+ if(*fd < 0) {
+ perror("cannot open fb0");
+ return -1;
+ }
+
+ if(ioctl(*fd, FBIOGET_FSCREENINFO, &fi) < 0) {
+ perror("failed to get fb0 info");
+ return -1;
+ }
+
+ if(ioctl(*fd, FBIOGET_VSCREENINFO, &vi) < 0) {
+ perror("failed to get fb0 info");
+ return -1;
+ }
+
+ bits = mmap(0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0);
+ if(bits == MAP_FAILED) {
+ perror("failed to mmap framebuffer");
+ return -1;
+ }
+
+ *width = vi.xres;
+ *height = vi.yres;
+ *fb = bits;
+ return 0;
+}
+
+static void set_active_framebuffer(int fd, unsigned n)
+{
+
+ if(n > 1) return;
+ vi.yres_virtual = vi.yres * 2;
+ vi.yoffset = n * vi.yres;
+ if(ioctl(fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
+ fprintf(stderr,"active fb swap failed!\n");
+ }
+}
+
+int main(int argc, const char *argv[]) {
+ int fd, width, height;
+ char* fb;
+ struct mdp_blit_req_list *req_list;
+ struct mdp_blit_req *req;
+ int srw, srh, drw, drh;
+ int srcx = 0; int srcy = 0;
+ int dstx = 10; int dsty = 10;
+
+ req_list = malloc(sizeof(struct mdp_blit_req_list) +
+ sizeof(struct mdp_blit_req));
+ req_list->count = 1;
+ req = req_list->req;
+
+ if (argc < 5)
+ printf("not enough args\n");
+ srw = atoi(argv[1]);
+ srh = atoi(argv[2]);
+ drw = atoi(argv[3]);
+ drh = atoi(argv[4]);
+
+ if (argc >= 7) {
+ srcx = atoi(argv[5]);
+ srcy = atoi(argv[6]);
+ }
+
+ if (argc == 9) {
+ dstx = atoi(argv[7]);
+ dsty = atoi(argv[8]);
+ }
+
+
+ if (get_framebuffer(&fd, &fb, &width, &height)) {
+ printf("couldnt' get fb\n");
+ return -1;
+ }
+ /*
+ req->src.width = 448;
+ req->src.height = 320;
+ */
+ req->src.width = vi.xres;
+ req->src.height = vi.yres;
+ req->src.format = MDP_RGB_565/*MDP_Y_CBCR_H2V2*/;
+ req->src.offset = 0;
+ req->src.memory_id = fd;
+ req->src_rect.x = srcx;
+ req->src_rect.y = srcy;
+ req->src_rect.w = srw;
+ req->src_rect.h = srh;
+
+ req->dst.width = vi.xres;
+ req->dst.height = vi.yres;
+ req->dst.format = MDP_RGB_565;
+ req->dst.offset = 0;
+ req->dst.memory_id = fd;
+ req->dst_rect.x = dstx;
+ req->dst_rect.y = dsty;
+ req->dst_rect.w = drw;
+ req->dst_rect.h = drh;
+ req->alpha = MDP_ALPHA_NOP;
+ req->transp_mask = MDP_TRANSP_NOP;
+// req->flags = MDP_ROT_90;
+ req->flags = MDP_ROT_NOP;
+
+ if(ioctl(fd, MSMFB_BLIT, req_list))
+ fprintf(stderr, "crap, failed blit\n");
+ return 0;
+}