1 /* A simple program to test the communication between the matrox meteor
2 * driver and an user application in the continous sync capture mode.
4 * First the driver clears the mask and decrements the counter like it
5 * would in a normal application. Then it purpose does not handle these
6 * responsibilities to simulate an application falling behind. I use
7 * the HUP signal to work as if the some of the buffers were removed
8 * (the second couter is used to cleared the correct bits.
10 * build kernel with at least:
12 * options "METEOR_ALLOC_PAGES=301"
15 /* Copyright (c) 1995 Mark Tinguely and Jim Lowe
16 * All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. All advertising materials mentioning features or use of this software
27 * must display the following acknowledgement:
28 * This product includes software developed by Mark Tinguely and Jim Lowe
29 * 4. The name of the author may not be used to endorse or promote products
30 * derived from this software without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
41 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGE.
45 #include <sys/types.h>
47 #include <sys/fcntl.h>
48 /*#include <machine/ioctl_meteor.h> */
49 #include "/sys/i386/include/ioctl_meteor.h"
51 typedef unsigned char uint8
;
52 typedef signed char int8
;
57 struct meteor_mem
*common_mem
;
64 /* clear 4 oldest active bits */
65 common_mem
->active
&= ~(1 << (sig_cnt2
++ % 32));
66 common_mem
->active
&= ~(1 << (sig_cnt2
++ % 32));
67 common_mem
->active
&= ~(1 << (sig_cnt2
++ % 32));
68 common_mem
->active
&= ~(1 << (sig_cnt2
++ % 32));
69 /* lowat is low enough that I will need 2 hups to start saving again */
70 common_mem
->num_active_bufs
-= 4;
78 struct meteor_capframe capframe
;
80 printf("active %3d = %08x ", sig_cnt
,common_mem
->active
);
81 printf("# act %3d = %d\n", sig_cnt
, common_mem
->num_active_bufs
);
84 common_mem
->active
&= ~(1 << (sig_cnt
% 32));
85 common_mem
->num_active_bufs
--;
89 printf("data %08x\n", *((u_long
*) (y
+ (sig_cnt
% 32) *
90 common_mem
->frame_size
)));
91 if (++sig_cnt
>= 200) {
92 capframe
.command
=METEOR_CAP_STOP_FRAMES
;
94 if (ioctl(i
, METEORCAPFRM
, &capframe
) < 0) {
95 printf("METEORCAPFRM failed %d\n", errno
);
104 struct meteor_geomet geo
;
105 int height
, width
, depth
, frames
, size
;
106 struct meteor_capframe capframe
;
108 if ((i
= open("/dev/meteor", O_RDONLY
)) < 0) {
109 printf("open failed\n");
112 printf("test %d %d\n", errno
, i
);
114 height
= geo
.rows
= 120;
115 width
= geo
.columns
= 160;
116 frames
= geo
.frames
= 32;
117 depth
= 2; /* 2 bytes per pixel */
119 printf("ioctl %d %d\n", errno
, i
);
121 geo
.oformat
= METEOR_GEO_RGB16
;
123 if (ioctl(i
, METEORSETGEO
, &geo
) < 0) {
124 printf("METEORSETGEO failed %d\n", errno
);
128 printf("mmap %d %d\n", errno
, i
);
129 size
= ((width
*height
*depth
*frames
+4095)/4096)*4096;
130 y
=(uint8
*) mmap((caddr_t
)0, size
+ 4096, PROT_READ
|PROT_WRITE
,MAP_SHARED
, i
, (off_t
)0);
132 if (y
== (uint8
*) MAP_FAILED
) return (0);
134 common_mem
= (struct meteor_mem
*) (y
+ size
);
136 signal(1, hup_catcher
);
137 signal(31, usr2_catcher
);
139 capframe
.command
=METEOR_CAP_N_FRAMES
;
144 printf("ioctl %d %d\n", errno
, i
);
145 if (ioctl(i
, METEORCAPFRM
, &capframe
) < 0) {
146 printf("METEORCAPFRM failed %d\n", errno
);
150 printf("signal = %d\n", common_mem
->signal
);
151 printf("frame size = %d\n", common_mem
->frame_size
);
152 printf("buffers = %d\n", common_mem
->num_bufs
);
153 printf("hiwater = %d\n", common_mem
->hiwat
);
154 printf("lowater = %d\n", common_mem
->lowat
);
155 printf("active = %08x\n", common_mem
->active
);
156 printf("# active = %d\n", common_mem
->num_active_bufs
);
158 printf("sleep loop\n", errno
, i
);