annotate drivers/tdfx_vid_test.c @ 24511:263c0b282d90

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