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