2 .\" $FreeBSD: src/share/man/man4/man4.i386/meteor.4,v 1.10.2.4 2001/08/17 13:08:45 ru Exp $
9 .Nd "video capture driver"
15 driver provides support for a PCI
18 It allows the capture of 24 bit RGB, 16 bit RGB and 16 bit YUV
21 .Ss Meteor Driver Installation
24 card in your system, you need a computer
25 that supports the PCI (preferably the Type 2 or better) interface bus.
26 It is recommended that the system has more than 16 MB of RAM since this
27 capture card directly deposits the image to system RAM.
29 The files required for
33 .Bl -item -offset indent -compact
37 .Pa /sys/i386/include/ioctl_meteor.h
42 release versions 2.1 and earlier, the following patch files are also required:
44 .Bl -item -offset indent -compact
46 .Pa meteor/usr/sys/i386/i386/conf.patch
48 .Pa meteor/usr/sys/conf/files.patch
50 .Pa meteor/sys/i386/conf/LINT.patch
53 These files are available for anonymous FTP at:
54 .Pa ftp://joy.cs.ndsu.nodak.edu/pub/meteor.tgz
58 In the configuration file, add the line (as shown in
59 .Pa meteor/usr/sys/i386/conf/LINT.patch ) :
63 There is also a couple of optional parameters you may use:
64 .Bl -tag -width indent
65 .It Cd "options ""METEOR_ALLOC_PAGES=xxx"""
66 Specifies the number of contiguous pages to allocate when successfully
68 The default number of pages allocated by the kernel is 151.
69 This means that there are (151*4096) bytes available for use.
70 .It Cd "options METEOR_DEALLOC_PAGES"
71 Deallocate all pages when closing the device.
73 contiguously re-allocating new pages are very small.
75 behavior is to not deallocate pages.
76 .It Cd "options ""METEOR_DEALLOC_ABOVE=xxx"""
77 Deallocate all pages above the specified number.
79 to not deallocate above any pages.
82 Make and install the kernel.
84 Make the special file name:
86 .Dl "# mknod /dev/meteor0 c <major> 0"
88 The major number is determined by the placement of the device in
90 The patch supplied with the driver will make the major number 67.
92 .Ss Meteor Capture Modes
95 capture driver has three modes of capture operation.
102 This mode is the easiest and slowest to use.
103 This mode is great for
104 capturing a single field at little programming cost.
106 In this mode, the user opens the device, sets the capture mode
113 call to load the data into a buffer.
116 read 400x300 RGB24 into a viewable PPM file
118 #include <sys/fcntl.h>
119 #include <machine/ioctl_meteor.h>
124 #define SIZE (ROWS * COLS * 4)
127 struct meteor_geomet geo;
128 char buf[SIZE],b[4],header[16],*p;
131 if ((i = open("/dev/meteor0", O_RDONLY)) < 0) {
132 printf("open failed: %d\\n", errno);
135 /* set up the capture type and size */
139 geo.oformat = METEOR_GEO_RGB24 ;
141 if (ioctl(i, METEORSETGEO, &geo) < 0) {
142 printf("ioctl failed: %d\\n", errno);
148 if (ioctl(i, METEORSFMT, &c) < 0) {
149 printf("ioctl failed: %d\\n", errno);
153 c = METEOR_INPUT_DEV0;
155 if (ioctl(i, METEORSINPUT, &c) < 0) {
156 printf("ioctl failed: %d\\n", errno);
160 if ((c=read(i, &buf[0], SIZE)) < SIZE) {
161 printf("read failed %d %d %d\\n", c, i, errno);
167 if ((o = open("rgb24.ppm", O_WRONLY | O_CREAT, 0644)) < 0) {
168 printf("ppm open failed: %d\\n", errno);
172 /* make PPM header and save to file */
173 strcpy(&header[0], "P6 400 300 255 ");
174 header[2] = header[6] = header[10] = header[14] = '\\n';
175 write (o, &header[0], 15);
176 /* save the RGB data to PPM file */
177 for (p = &buf[0]; p < &buf[SIZE]; ) {
178 b[2] = *p++; /* blue */
179 b[1] = *p++; /* green */
180 b[0] = *p++; /* red */
181 *p++; /* NULL byte */
182 write(o,&b[0], 3); /* not very efficient */
189 Memory mapped single capture or unsynchronized continuous capture.
191 The single capture mode is designed for conferencing tools such as
193 These tools need to control the starting of the image capture and also
194 need several frames a second.
195 The continuous capture mode is designed
196 for applications that want free-running data.
198 In this mode, the user opens the device, sets the capture mode
205 memory into the user process space, and issues either the
206 single-capture or the continuous capture call (see:
209 call) to load the data into the memory mapped buffer.
214 call, the single frame capture
216 will block until the capture is complete, the continuous capture
217 will return immediately.
219 .Pa meteor_mmap_single_continuous.c
221 #include <sys/types.h>
222 #include <sys/mman.h>
223 #include <sys/fcntl.h>
224 #include <machine/ioctl_meteor.h>
229 #define SIZE (ROWS * COLS * 2)
232 struct meteor_geomet geo;
237 if ((i = open("/dev/meteor0", O_RDONLY)) < 0) {
238 printf("open failed\\n");
245 geo.oformat = METEOR_GEO_RGB16 ;
247 if (ioctl(i, METEORSETGEO, &geo) < 0) {
248 printf("ioctl failed: %d\\n", errno);
254 if (ioctl(i, METEORSFMT, &c) < 0) {
255 printf("ioctl failed: %d\\n", errno);
259 c = METEOR_INPUT_DEV0;
261 if (ioctl(i, METEORSINPUT, &c) < 0) {
262 printf("ioctl failed: %d\\n", errno);
266 mmbuf=(char *)mmap((caddr_t)0, SIZE, PROT_READ,
267 MAP_SHARED, i, (off_t)0);
270 /* single frame capture */
271 c = METEOR_CAP_SINGLE ;
272 ioctl(i, METEORCAPTUR, &c); /* wait for the frame */
274 /* directly access the frame buffer array data in mmbuf */
276 /* continuous frame capture */
277 c = METEOR_CAP_CONTINOUS ;
278 ioctl(i, METEORCAPTUR, &c); /* returns immediately */
280 /* directly access the frame buffer array data in mmbuf */
282 c = METEOR_CAP_STOP_CONT ;
283 ioctl(i, METEORCAPTUR, &c); /* close will also stop capture */
291 Memory mapped, multi-frame ring buffer synchronize capture.
293 This continuous capture mode is synchronized with the application that
294 processes up to 32 frames.
295 This gives the advantages of both single and
296 continuous capture modes.
298 The kernel notifies the application of a new data by raising an
299 application defined signal.
300 The driver also shares a structure with
301 the application that allows them to communicate which frame has been
302 written by the kernel and which frame has been read by the application.
304 The shared structure starts on the first page after your data.
306 structure address can be found by calculation:
308 .Dl "(number_rows * number_columns * pixel_depth + 4095) & 0xfffff000"
310 .Dl "((number_rows * number_columns * pixel_depth + 4095)/4096) * 4096"
312 The shared structure is of type
313 .Va struct meteor_mem .
315 important fields are called
320 is a bitmap of frames written by the kernel.
323 a count of frames marked in the
327 in by the driver, the
329 count is tested, if this
330 count is below the threshold of number of active frames (value
334 variable), the bit representing frame
335 number in the buffer is stored in the
339 is incremented, the kernel then raises the specified
340 signal to activate the user application.
341 The user application's
342 responsibility when getting the signal is to check the active bitmap
343 to determine the lowest active frame, use the data as the application
344 desires, clear the bitmap entry for that frame, and decrement the
345 .Va num_active_bufs .
346 If the threshold of number of active frames
348 has been exceeded, no new frames or signal from the kernel will occur
351 is less than or equal to
354 The driver loads the frames in a round-robin fashion.
356 that the user removes them in the same order.
358 check to see if the frame is already active.
362 and number of frames in the buffer are also provided
365 structure, but changing these fields in the
366 application will not change the operation of the driver.
368 In programming for this mode, the user opens the device, sets the
371 the data/common control structure, then starts the
372 continuous capture mode.
373 A special signal catcher is required to
374 process the frames as they are read by the kernel.
376 When specifying the geometry (see:
381 is important that the number of frames is set greater than 1.
383 .Pa skeleton_capture_n.c
385 #include <sys/types.h>
386 #include <sys/mman.h>
387 #include <sys/fcntl.h>
388 #include <sys/signal.h>
389 #include <machine/ioctl_meteor.h>
391 int video; /* made global if you wish to stop capture in signal handler */
393 struct meteor_mem *common_mem;
402 struct meteor_capframe capframe; /* for ioctl */
407 frame = (char *) (data_frames + sig_cnt * common_mem->frame_size) ;
409 /* add frame processing here */
410 /* deactivate frame */
411 common_mem->active &= ~(1 << (sig_cnt % 16));
412 common_mem->num_active_bufs--;
414 /* process next frame on next interrupt */
415 sig_cnt = ((sig_cnt+1) % FRAME_MAX);
418 if (some_condition_requiring_stopping) {
419 capframe.command=METEOR_CAP_STOP_FRAMES;
421 if (ioctl(i, METEORCAPFRM, &capframe) < 0) {
422 printf("METEORCAPFRM failed %d\\n", errno);
431 struct meteor_geomet geo;
432 int height, width, depth, frames, size;
433 struct meteor_capframe capframe;
435 if ((i = open("/dev/meteor0", O_RDONLY)) < 0) {
436 printf("open failed\\n");
439 printf("test %d %d\\n", errno, i);
441 height = geo.rows = 120;
442 width= geo.columns = 320;
443 frames = geo.frames = FRAME_MAX;
444 depth = 2; /* 2 bytes per pixel for RGB*/
447 geo.oformat = METEOR_GEO_RGB16;
449 if (ioctl(i, METEORSETGEO, &geo) < 0) {
450 printf("METEORSETGEO failed %d\\n", errno);
456 if (ioctl(i, METEORSFMT, &c) < 0) {
457 printf("ioctl failed: %d\\n", errno);
461 c = METEOR_INPUT_DEV0;
463 if (ioctl(i, METEORSINPUT, &c) < 0) {
464 printf("ioctl failed: %d\\n", errno);
468 size = ((width*height*depth*frames+4095)/4096)*4096;
469 /* add one page after data for meteor_mem */
470 data_frames = mmap((caddr_t)0, size + 4096, PROT_READ | PROT_WRITE,
471 MAP_SHARED, i, (off_t)0);
473 if (data_frames == (caddr_t) MAP_FAILED) return (0);
475 /* common_mem is located at page following data */
476 common_mem = (struct meteor_mem *) (y + size);
478 signal(SIGUSR2, usr2_catcher); /* catch new frame message */
480 capframe.command=METEOR_CAP_N_FRAMES;
481 capframe.signal=SIGUSR2;
482 capframe.lowat=12; /* must be < hiwat */
483 capframe.hiwat=14; /* must be < FRAME_MAX */
485 /* start the sync capture */
486 if (ioctl(i, METEORCAPFRM, &capframe) < 0) {
487 printf("METEORCAPFRM failed %d\\n", errno);
491 /* this is the background working area, or you can sleep */
494 /* to stop capture */
495 capframe.command=METEOR_CAP_STOP_FRAMES;
497 if (ioctl(i, METEORCAPFRM, &capframe) < 0) {
498 printf("METEORCAPFRM failed %d\\n", errno);
504 .Ss Meteor IOCTL Call and Parameters
509 requests for capturing, reading card
510 status, for setting and reading the geometry, and for setting and reading the
514 IT IS VERY IMPORTANT TO CHECK FOR ERRORS ON THESE RETURNING IOCTLs.
516 Errors indicate that something is very wrong with the
519 application should not attempt to proceed further with capturing.
522 capture driver still makes attempts to stop the next capture step if
523 an error occurred in a previous step but was ignored by the application
536 are used to set and read the input
537 size, input device, and output format for frame capture.
543 structure that has the
546 .Bl -tag -width columns
548 number of rows (lines high) in output image
550 number of pixels in a row (width) in output image
552 number of frames in buffer.
553 Should be 1, unless using
554 the multi-framed synchronous capture mode
556 which REQUIRES frames to be larger than 1.
563 the existing values are used.
567 you may choose one of the following output format:
568 .Bl -tag -width METEOR_GEO_YUV_PACKED
569 .It Dv METEOR_GEO_RGB16
570 (RGB 16 bits xrrrrrgg gggbbbbb default)
571 .It Dv METEOR_GEO_RGB24
572 (RGB 24 bits packed in 32 bits:
573 00000000 rrrrrrrr gggggggg bbbbbbbb)
574 .It Dv METEOR_GEO_YUV_PACKED
575 (4-2-2 YUV 16 bits packed byte format:
576 u0 y0 v0 y1 u1 y2 v1 y3 ...)
577 .It Dv METEOR_GEO_YUV_PLANER
578 (4-2-2 YUV 16 bits planer format:
579 rows * columns bytes of y
580 rows * column / 4 bytes of even u
581 rows * column / 4 bytes of even v
582 rows * column / 4 bytes of odd u
583 rows * column / 4 bytes of odd v)
590 will fail if more than one entry from a category
592 It is highly recommended that a
595 before capturing data because you cannot guarantee the initial mode
600 will also attempt to reallocate a new contiguous
601 kernel buffer if the new geometry exceeds the old geometry.
603 other hand, if the new geometry will fit in the existing buffer,
604 the existing buffer is used.
610 will return a value of -1 and the
619 .Va rows , columns , frames
622 could not allocate the contiguous block.
634 are used to set and read the camera input
637 Possible formats are:
639 .Bl -tag -width METEOR_FMT_AUTOMODE -compact
640 .It Dv METEOR_FMT_NTSC
642 .It Dv METEOR_FMT_PAL
644 .It Dv METEOR_FMT_SECAM
646 .It Dv METEOR_FMT_AUTOMODE
659 are used to set and read the camera
661 Using the DB9 connector on the
664 devices can be connected and an input camera can be selected with this
667 Possible formats are:
669 .Bl -tag -width METEOR_INPUT_DEV_SVIDEO -compact
670 .It Dv METEOR_INPUT_DEV0
671 (default if none specified)
672 .It Dv METEOR_INPUT_DEV_RCA
673 (same as METEOR_INPUT_DEV0)
674 .It Dv METEOR_INPUT_DEV1
675 .It Dv METEOR_INPUT_DEV2
676 .It Dv METEOR_INPUT_DEV_SVIDEO
677 (same as METEOR_INPUT_DEV2)
685 is used to read the status of the
688 and returns the following information:
689 .Bl -column "METEOR_STATUS_ID_MASK" ""
690 .It Dv METEOR_STATUS_ID_MASK " 4 bit ID of the SAA7196 scaler chip."
692 .It Dv METEOR_STATUS_DIR " 0 = scaler uses internal source."
693 .It " 1 = scaler uses external data of expansion bus."
695 .It Dv METEOR_STATUS_OEF " 0 = even field detected."
696 .It " 1 = odd field detected."
698 .It Dv METEOR_STATUS_SVP " VRAM Port state:"
699 .It " 0 = inputs HFL and INCADDR inactive."
700 .It " 1 = inputs HFL and INCADDR active."
702 .It Dv METEOR_STATUS_STTC " 0 = TV horizontal time constant (slow)."
703 .It " 1 = VCR horizontal time constant (fast)."
705 .It Dv METEOR_STATUS_HCLK " 0 = Horizontal Phase Lock Loop locked."
706 .It " 1 = Horizontal Phase Lock Loop unlocked."
708 .It Dv METEOR_STATUS_FIDT " 0 = 50 Hz Field detected."
709 .It " 1 = 60 Hz Field detected."
711 .It Dv METEOR_STATUS_ALTD " 0 = no line alternating color burst detected."
712 .It " 1 = line alternating color burst detected (PAL/SECAM)."
714 .It Dv METEOR_STATUS_CODE " 0 = no color information detected."
715 .It " 1 = color information detected."
723 is used to single frame capture or unsynchronized
726 The single frame capture
728 request will return only after a
729 frame has been captured and transfered to the frame buffer.
731 The unsynchronized continuous capture will return immediately and
732 data is directly deposited into the buffer when it is available.
733 Since this is unsynchronized, it is possible the data is being
734 written by the kernel while being read by the application.
738 routines use the following settings:
740 .Bl -tag -width METEOR_CAP_CONTINOUS -compact
741 .It Dv METEOR_CAP_SINGLE
743 .It Dv METEOR_CAP_CONTINOUS
744 unsynchronized continuous capture
745 .It Dv METEOR_CAP_STOP_CONT
746 stop the unsynchronized continuous
754 will return a value of -1 and the
760 invalid capture command value
762 there is not internal buffer to hold the frame.
763 This indicates the previous set geometry
767 card is already capturing.
775 is used for synchronous capture of multiple frames.
781 structure that has the
783 .Bl -tag -width command
788 .Bl -tag -width METEOR_CAP_STOP_FRAMES
789 .It Dv METEOR_CAP_STOP_FRAMES
790 stop the capture; does not use the
791 other variable in structure.
792 .It Dv METEOR_CAP_N_FRAMES
793 start the capture using the other
794 variables in the structure as inputs
797 signal to send to application when a new
798 frame has been captured.
800 only be raised if the captured frame is saved.
807 When a new frame is completed, the driver checks the current unread
808 frame count stored in shared variable (the shared variable is stored
813 if the count is larger
816 the driver will not store any new frames and will not
817 send capture signal to the user application until the
826 will return a value of -1 and the
832 invalid meteor_geomet structure pointer or bad command.
834 there is not internal buffer to hold the frame.
835 This indicates the previous set geometry
839 card is already capturing.
851 are used to set and get the chrominance
852 gain control and effects the UV output amplitude.
861 of -1 and the external variable
866 invalid unsigned char pointer.
878 are used to get and set the hue.
880 signed character has legal values are from +127 which represent
881 +178.6 degrees to -128 which represents -180 degrees.
889 will return a value of
890 -1 and the external variable
895 invalid signed char pointer.
905 is used to get the count of frame errors, DMA errors and
906 count of the number of frames captured that have occurred since
907 the device was opened.
909 can be used to reinitialize the
916 structure that has the
918 .Bl -tag -width frame_count
920 number of FIFO errors since device was opened.
922 number of DMA errors since device was opened.
924 number of frames captured since device was opened.
934 of -1 and the external variable
939 invalid meteor_counts structure pointer.
945 IIC register is difficult to set.
946 We got around that by adding a long
947 wait at each IIC register write.
949 We had difficulties getting the
951 capture card to work on systems
952 that used NCR chipset SCSI cards.
953 It is possible that the
957 could work together using the newer TRITON motherboards.
960 .An Jim Lowe Aq james@miller.cs.uwm.edu ,
961 .An Mark Tinguely Aq tinguely@plains.nodak.edu