[Prev][Next][Index][Thread]

No Subject



Subject: qcam port to FreeBSD

We have ported your qcam to FreeBSD. If you are interested we have
included 
in this mail the diff needed to create qcam-FreeBSD.c from
qcam-Linux.c 
Makefile also had to be tweeked so it's diffs have been included too. 
qcam-lib.c also had a minor tweek - diffs included.

==============================X====================================
Diffs for qcam-Linux.c to create qcam-FreeBSD.c follow
NOTE: qcam-Linux.h must also be copied to qcam-FreeBSD.h
------------------------------x------------------------------------

1c1
< /* qcam-Linux.c -- Linux-specific routines for accessing QuickCam */
---
> /* qcam-FreeBSD.c -- FreeBSD-specific routines for accessing
QuickCam */
34,39c34,35
< #include <asm/io.h>
< 
< #include <sys/time.h>
< #include <sys/types.h>
< #include <sys/stat.h>
< #include <fcntl.h>
---
> /* This is where inb and outb are hidden */
> #include <machine/cpufunc.h>
42c38,41
< #include "qcam-Linux.h"
---
> #include "qcam-FreeBSD.h"
> 
> /* No ioperm function under FreeBSD - open /dev/io instead */
> FILE * IOPerm;
44,48c43,57
< int read_lpstatus(struct qcam *q) { return inb(q->port+1); }
< int read_lpcontrol(struct qcam *q) { return inb(q->port+2); }
< int read_lpdata(struct qcam *q) { return inb(q->port); }
< void write_lpdata(struct qcam *q, int d) { outb(d,q->port); }
< void write_lpcontrol(struct qcam *q, int d) { outb(d,q->port+2); }
---
> int read_lpstatus(struct qcam *q) { 
>   return( (int) inb( (unsigned int)(q->port+1) ) ); 
> }
> int read_lpcontrol(struct qcam *q) { 
>   return( (int) inb( (unsigned int)(q->port+2) ) ); 
> }
> int read_lpdata(struct qcam *q) { 
>   return( (int) inb( (unsigned int)(q->port) ) ); 
> }
> void write_lpdata(struct qcam *q, int d) { 
>   outb( (unsigned int)(q->port), (unsigned char)d );
> }
> void write_lpcontrol(struct qcam *q, int d) { 
>   outb( (unsigned int)(q->port+2) ,(unsigned char)d ); 
> }
53,54c62,65
<   if(q->port>0x3bc) return 1; 
<   return (ioperm(q->port, 3, 1));
---
>   if(q->port>0x3b8) return 1; 
>   if( (IOPerm = fopen("/dev/io","r"))!=NULL ) 
>     return 0;
>   else return 1; 
59c70
<   return (ioperm(q->port, 3, 0));
---
>   return (fclose(IOPerm));
142d152
< 


==============================X====================================

Diffs on Makefile for FreeBSD follow
------------------------------x------------------------------------

1c1
< # Makefile for QCAM under Linux
---
> # Makefile for QCAM under FreeBSD
35c35
< 	$(CC) $(LDFLAGS) -o qcam qcam.o -L. -lqcam
---
> 	$(CC) $(LDFLAGS) -L. qcam.o -o qcam -lqcam
38c38
< 	ln -sf qcam-`uname`.h qcam-os.h
---
> 	ln -sf qcam-FreeBSD.h qcam-os.h
41c41
< 	ln -sf qcam-`uname`.c qcam-os.c
---
> 	ln -sf qcam-FreeBSD.c qcam-os.c
48a49,51
> xqcam.o: xqcam.c qcam.h qcam-os.h
> 	$(CC) $(CFLAGS) -I/usr/X11R6/include -c xqcam.c
> 
62d64
< 	
66c68
< 	ar rcs $@ $^ 
---
> 	ar r $@ qcam-lib.o qcam-os.o

==============================X====================================

Diffs on qcam-lib.c for FreeBSD follow
------------------------------x------------------------------------

38a39
> #include <sys/errno.h>
160,162c161
<   f=fopen(CONFIG_FILE,"r");
< 
<   if (f==NULL&&errno!=ENOENT) {
---
>   if( !(f=fopen(CONFIG_FILE,"r")) ) {

------------------------------x------------------------------------