comparison drivers/tdfx_vid_tst.c @ 9545:d1bbeae9f46a

tdfx_vid a new kernel driver for tdfx wich let use agp move :)
author albeu
date Fri, 07 Mar 2003 18:42:08 +0000
parents
children
comparison
equal deleted inserted replaced
9544:97f61ffa441e 9545:d1bbeae9f46a
1
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <sys/mman.h>
9 #include <sys/ioctl.h>
10 #include <inttypes.h>
11
12 #include "tdfx_vid.h"
13
14
15 static void print_tdfd_vid_cfg(tdfx_vid_config_t* cfg) {
16 printf("tdfx_vid version %d\n"
17 " Ram: %d\n"
18 " Screen: %d x %d\n",
19 cfg->version,
20 cfg->ram_size,
21 cfg->screen_width, cfg->screen_height);
22 }
23
24
25 int main(int argc, char** argv) {
26 int fd,i;
27 unsigned char *mem,*ptr;
28 tdfx_vid_agp_move_t move;
29 tdfx_vid_config_t cfg;
30 tdfx_vid_blit_t blit;
31
32 fd = open("/dev/tdfx_vid", O_RDWR);
33
34 if(fd <= 0) {
35 printf("Can't open /dev/tdfx_vid\n");
36 return 1;
37 }
38
39 if(ioctl(fd,TDFX_VID_GET_CONFIG,&cfg)) {
40 printf("Ioctl GET_CONFIG error\n");
41 close(fd);
42 return 1;
43 }
44
45 print_tdfd_vid_cfg(&cfg);
46
47 mem = mmap( NULL, 640*480*2, PROT_READ | PROT_WRITE, MAP_SHARED,
48 fd, 0);
49
50 if(mem == MAP_FAILED) {
51 printf("Memmap failed !!!!!\n");
52 return 1;
53 }
54
55 /* for(ptr = mem, i = 0 ; i < 640*480 ; i++) { */
56 /* ptr[0] = i & 0xFF; */
57 /* ptr[1] = (i & 0xFF); */
58 /* ptr += 2; */
59 /* } */
60
61 memset(mem,0xFF,640*480*2);
62
63 memset(&move, 0, sizeof(tdfx_vid_agp_move_t));
64 move.width = 640;
65 move.height = 240;
66 move.src_stride = 640;
67 move.dst_stride = 640*2;
68
69 if(ioctl(fd,TDFX_VID_AGP_MOVE,&move)) {
70 printf("AGP Move failed !!!!\n");
71 return 0;
72 }
73
74 printf("AGP Move ????\n");
75 sleep(1);
76
77 blit.src = 0;
78 blit.src_stride = 640*2;
79 blit.src_x = blit.src_y = 0;
80 blit.src_w = 320;
81 blit.src_h = 240;
82 blit.src_format = cfg.screen_format;
83
84 blit.dst = 240*640*2+320;
85 blit.dst_stride = 640*2;
86 blit.dst_x = blit.dst_y = 0;
87 blit.dst_w = 320;
88 blit.dst_h = 240;
89 blit.dst_format = cfg.screen_format;
90
91 if(ioctl(fd,TDFX_VID_BLIT,&blit)) {
92 printf("Blit failed !!!!\n");
93 return 0;
94 }
95
96 close(fd);
97 return 1;
98 }