new interface_pp_overhaul+timer patch

sbertin@mindspring.com sbertin@mindspring.com
Tue, 31 Aug 1999 23:20:40 -0400 (EDT)


--0-1804289383-936156046=:1986
Content-Type: TEXT/plain; CHARSET=US-ASCII

Here is another combined patch against cpia-0.2. It has my first patch,
Peter's latest timer patch, and some new improvements.

New features:
	Module parameter parport to specify which parallel port(s) to
	use.  This overrides the auto probing and is the same as lp's
	parport option.

	MAXCAMS increased to PARPORT_MAX (8)

	No more explicit dependence on parport_pc, might work with other
	parallel port hardware (untested).

	Some changes to support compiling into the kernel instead of as
	a module.  It is likely that more changes are needed for this.

	Change to the parameters to if_Init in interface.h to allow
	parameters to be passed to the low level driver when compiled
	into the kernel.

	camera entries are dynamically allocated again instead of the
	static array I used in my last patch.

Still to do (for interface_pp.c):
	Better detection of cameras when parport_probe is not available.
	I haven't even looked at the camera docs yet, so I would
	appreciate it if someone else could do this.  BTW: Has anybody
	tested the autodetection with any camera other than the Creative
	Labs WebCamII yet?

	Allow arbitrary minor numbers rather than just [0..MAXCAMS-1]. 
	I believe this is needed for v4l2.  I've been thinking about
	this and can probably put it together pretty quickly.

	Anything else?

Scott J. Bertin
sbertin@mindspring.com


--0-1804289383-936156046=:1986
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: interface_pp_overhaul2+timer-1.patch

diff -c -r cpia.old/client/x11.c cpia/client/x11.c
*** cpia.old/client/x11.c	Thu May 13 16:59:16 1999
--- cpia/client/x11.c	Sat Aug 28 18:50:19 1999
***************
*** 63,69 ****
  	return -1;
  	};
  
! display_bits = info->bits_per_rgb * 3;
  display_bytes = (display_bits+7) >> 3; //round up ...
  
  printf("x11: color depth: %d bits, %d bytes\n",display_bits,display_bytes);
--- 63,69 ----
  	return -1;
  	};
  
! display_bits = info->depth;
  display_bytes = (display_bits+7) >> 3; //round up ...
  
  printf("x11: color depth: %d bits, %d bytes\n",display_bits,display_bytes);
diff -c -r cpia.old/module/Makefile cpia/module/Makefile
*** cpia.old/module/Makefile	Sat May 15 07:56:37 1999
--- cpia/module/Makefile	Tue Aug 31 22:00:14 1999
***************
*** 3,9 ****
  WARN     = -Wall -Wstrict-prototypes
  OPTIMIZE = -O2 -pipe
  CODESTYL = -fomit-frame-pointer -fno-strength-reduce
! INCLUDES = -I../include
  DEFINES  = -D__KERNEL__ -DMODULE
  CFLAGS   = $(DEBUG) $(WARN) $(OPTIMIZE) $(CODESTYL) $(INCLUDES) $(DEFINES)
  LIBS     =
--- 3,9 ----
  WARN     = -Wall -Wstrict-prototypes
  OPTIMIZE = -O2 -pipe
  CODESTYL = -fomit-frame-pointer -fno-strength-reduce
! INCLUDES = -I../include -I/usr/src/linux/include
  DEFINES  = -D__KERNEL__ -DMODULE
  CFLAGS   = $(DEBUG) $(WARN) $(OPTIMIZE) $(CODESTYL) $(INCLUDES) $(DEFINES)
  LIBS     =
***************
*** 18,27 ****
  	$(CC) -c $(CFLAGS) $<
  
  ppcuscpia.o: $(PPCUS)
! 	$(LD) -s -r -o $@ $^ ../shared/procs.o
  
  ppv4l2cpia.o: $(PPV4L2)
! 	$(LD) -s -r -o $@ $^ ../shared/procs.o
  
  clean:
  	rm -f *.o *~ core .depend DEADJOE
--- 18,27 ----
  	$(CC) -c $(CFLAGS) $<
  
  ppcuscpia.o: $(PPCUS)
! 	$(LD) -r -o $@ $^ ../shared/procs.o
  
  ppv4l2cpia.o: $(PPV4L2)
! 	$(LD) -r -o $@ $^ ../shared/procs.o
  
  clean:
  	rm -f *.o *~ core .depend DEADJOE
diff -c -r cpia.old/module/cpia_entry.h cpia/module/cpia_entry.h
*** cpia.old/module/cpia_entry.h	Sun May 16 13:59:56 1999
--- cpia/module/cpia_entry.h	Mon Aug 30 18:59:01 1999
***************
*** 19,24 ****
--- 19,27 ----
  struct parport			*port;
  enum comstates			state;
  enum camstates			camstate;
+ struct wait_queue               *q_wait;
+ struct timer_list               q_timer;
+ int				open_count;
  };
  
  #endif
diff -c -r cpia.old/module/interface.h cpia/module/interface.h
*** cpia.old/module/interface.h	Thu May 13 14:32:19 1999
--- cpia/module/interface.h	Tue Aug 31 21:15:21 1999
***************
*** 7,13 ****
  int 			if_StreamRead (int minor,unsigned char*,int);
  int			if_Open(int minor);
  int			if_Close(int minor);
! int			if_Init(void);
  int			if_Cleanup(void);
  
  #endif
--- 7,13 ----
  int 			if_StreamRead (int minor,unsigned char*,int);
  int			if_Open(int minor);
  int			if_Close(int minor);
! int			if_Init(char *str, int *ints);
  int			if_Cleanup(void);
  
  #endif
diff -c -r cpia.old/module/interface_pp.c cpia/module/interface_pp.c
*** cpia.old/module/interface_pp.c	Sun May 16 16:04:39 1999
--- cpia/module/interface_pp.c	Tue Aug 31 22:00:18 1999
***************
*** 1,5 ****
--- 1,13 ----
  
  // (C) 1999 Bas Huisman <bhuism@cs.utwente.nl>
+ //          and Scott J. Bertin <sbertin@mindspring.com>
+ 
+ #define __NO_VERSION__
+ #include <linux/module.h>
+ #undef __NO_VERSION__
+ #include <linux/init.h>
+ 
+ #include <linux/config.h>
  
  #include <linux/parport.h>
  
***************
*** 9,20 ****
  #include "procs.h"
  #include "debug.h"
  
! #define MAXCAMS		4
  #define PACKET_LENGTH 	8
  
! struct	cpia_entry *camera[MAXCAMS];
  
! char camstatesstr[12][40] = {
  		"CPIA_PHASE_idle",
  		"CPIA_PHASE_neg2s",
  		"CPIA_PHASE_setup",
--- 17,65 ----
  #include "procs.h"
  #include "debug.h"
  
! #ifdef CONFIG_KMOD
! #include <linux/kmod.h>
! #endif
! 
! #define MAXCAMS		PARPORT_MAX
  #define PACKET_LENGTH 	8
  
! /* These should be defined in linux/parport.h, but aren't.  The #ifndef
!  * parport_enable_irq is in case they are at some future time.
!  */
! #ifdef PARPORT_NEED_GENERIC_OPS
! #ifndef parport_enable_irq
! #define parport_enable_irq(p) (p)->ops->enable_irq(p)
! #define parport_disable_irq(p) (p)->ops->disable_irq(p)
! #endif /* parport_enable_irq */
! #else /* !PARPORT_NEED_GENERIC_OPS */
! #ifndef parport_enable_irq
! #define parport_enable_irq(p) parport_pc_enable_irq(p)
! #define parport_disable_irq(p) parport_pc_disable_irq(p)
! #endif /* parport_enable_irq */
! #endif /* !PARPORT_NEED_GENERIC_OPS */
! 
! static struct	cpia_entry *camera[MAXCAMS] =
! 	{ [0 ... MAXCAMS-1] = NULL };
! 
! /* Magic numbers for defining port-device mappings */
! #define PPCPIA_PARPORT_UNSPEC -4
! #define PPCPIA_PARPORT_AUTO -3
! #define PPCPIA_PARPORT_OFF -2
! #define PPCPIA_PARPORT_NONE -1
! 
! #ifdef MODULE
! static int parport_nr[MAXCAMS] = { [0 ... MAXCAMS-1] = PPCPIA_PARPORT_UNSPEC };
! static char *parport[MAXCAMS] = { NULL,  };
! 
! MODULE_PARM(parport, "1-" __MODULE_STRING(MAXCAMS) "s");
! MODULE_PARM_DESC(parport, "'auto' or a list of parallel port numbers. Just like lp.");
! #else
! static int parport_nr[MAXCAMS] __initdata = { [0 ... MAXCAMS-1] = PPCPIA_PARPORT_UNSPEC };
! static int parport_ptr = 0;
! #endif
  
! static char camstatesstr[12][40] = {
  		"CPIA_PHASE_idle",
  		"CPIA_PHASE_neg2s",
  		"CPIA_PHASE_setup",
***************
*** 28,72 ****
  
  // ***************************************************************************
  //
- //  struct cpia_entry stuff
- //
- // ***************************************************************************
- 
- int newcamera(void)
- {
- int i;
- for (i = 0;i < MAXCAMS;i++)
- 	{
- 	if (camera[i] == NULL)
- 		{
- 		camera[i] = kmalloc(sizeof(struct cpia_entry),GFP_KERNEL);
- 		if (!camera[i])
- 			{
- 			LOG("kmalloc failed\n");
- 			return -1;
- 			};
- 		return i;
- 		};
- 	};
- LOG("reached MAXCAMS camera's increase MAXCAMS\n");
- return -1;
- };
- 
- int freecam(int camnr)
- {
- if (camera[camnr])
- 	{
- 	kfree(camera[camnr]);
- 	camera[camnr] = NULL;
- 	return 0;
- 	};
- LOG("hmm.. trying to free a unkmalloc'ed camera\n");
- return -1;
- };
- 
- 
- // ***************************************************************************
- //
  //  EndTransferMode
  //
  // ***************************************************************************
--- 73,78 ----
***************
*** 76,82 ****
  if (!cpia) return;
  if (cpia->state == CPIA_REVERSE) Reverse2Forward(cpia);
  Valid1284Termination(cpia);
! parport_pc_enable_irq(cpia->port);
  };
  
  // ***************************************************************************
--- 82,88 ----
  if (!cpia) return;
  if (cpia->state == CPIA_REVERSE) Reverse2Forward(cpia);
  Valid1284Termination(cpia);
! parport_enable_irq(cpia->port);
  };
  
  // ***************************************************************************
***************
*** 87,93 ****
  
  int ForwardSetup(struct cpia_entry *cpia)
  {
! parport_pc_disable_irq(cpia->port);
  if (!Negotiate2SetupPhase(cpia,0))
  	{
  	if (!ECPSetupPhase(cpia)) return 0;
--- 93,99 ----
  
  int ForwardSetup(struct cpia_entry *cpia)
  {
! parport_disable_irq(cpia->port);
  if (!Negotiate2SetupPhase(cpia,0))
  	{
  	if (!ECPSetupPhase(cpia)) return 0;
***************
*** 106,112 ****
  
  int ReverseSetup(struct cpia_entry *cpia,int extensibility)
  {
! parport_pc_disable_irq(cpia->port);
  if (!Negotiate2SetupPhase(cpia,extensibility))
  	{
  	if (!ECPSetupPhase(cpia))
--- 112,118 ----
  
  int ReverseSetup(struct cpia_entry *cpia,int extensibility)
  {
! parport_disable_irq(cpia->port);
  if (!Negotiate2SetupPhase(cpia,extensibility))
  	{
  	if (!ECPSetupPhase(cpia))
***************
*** 121,133 ****
  return -1;
  };
  
! void pp_irq_handler(int irq,void *a,struct pt_regs *b)
  {
! int minor = 0; //fixme
! if (camera[minor])
  	{
! 	if (camera[minor]->camstate == CPIA_PHASE_idle) LOG("image ready (%ld)\n",jiffies);
! 	//LOG("(%ld)got IRQ when in %s\n",jiffies,camstatesstr[camera[minor]->camstate]);
  	};
  };
  
--- 127,139 ----
  return -1;
  };
  
! void pp_irq_handler(int irq,void *handle,struct pt_regs *b)
  {
! struct cpia_entry *cam = (struct cpia_entry *)handle;
! if (cam)
  	{
! 	//if (cam->camstate == CPIA_PHASE_idle) LOG("image ready (%ld)\n",jiffies);
! 	//LOG("(%ld)got IRQ when in %s\n",jiffies,camstatesstr[cam->camstate]);
  	};
  };
  
***************
*** 146,155 ****
  int if_StreamRead(int minor,unsigned char *buffer,int length)
  {
  int tmp = 0;
! if (!camera[minor]) return -1;
! if (ReverseSetup(camera[minor],1)) return -1;
! tmp = ECPReadBuffer(camera[minor],buffer,length);
! EndTransferMode(camera[minor]);
  return tmp;
  };
  
--- 152,161 ----
  int if_StreamRead(int minor,unsigned char *buffer,int length)
  {
  int tmp = 0;
! struct cpia_entry	*cpia = camera[minor];
! if (ReverseSetup(cpia,1)) return -1;
! tmp = ECPReadBuffer(cpia,buffer,length);
! EndTransferMode(cpia);
  return tmp;
  };
  
***************
*** 170,177 ****
  int			databytes;
  struct cpia_entry	*cpia = camera[minor];
  
- if (!camera[minor]) return -1;
- 
  if ((ioctlnr<0)||(ioctlnr >= ((sizeof(ioctl2proc))/sizeof(ioctl2proc[0]))))
  	{
  	LOG("illegal ioctlnr %d\n",ioctlnr);
--- 176,181 ----
***************
*** 255,318 ****
  
  int if_Open(int minor)
  {
! struct parport *port = NULL;
! struct pardevice *pdev = NULL;
! int camnr;
! 
! if (camera[minor])  // if cpia_arr[minor]
! 	{
! 	LOG("camera[%d] != NULL already opened this thing ?\n",minor);
! 	return -EBUSY;
! 	};
! 
! for (port = parport_enumerate();port;port = port->next)
! 	{
! 	if (port->number == minor) break;
! 	};
! 
! if (!port)
! 	{
! 	LOG("can't find parport number %d\n",minor);
! 	return -ENXIO;
! 	};
! 
! if (!port->modes & PARPORT_MODE_PCECP) //fixme
  	{
! 	LOG("port is not ECP capable\n");
  	return -ENXIO;
  	};
  
! pdev = parport_register_device(port,"cpia",NULL,NULL,pp_irq_handler,0,NULL);
! 
! if (!pdev)
  	{
! 	LOG("failed to parport_register_device\n");
! 	return -ENXIO;
  	}
  
! if (parport_claim(pdev))
  	{
  	LOG("failed to claim the port\n");
- 	parport_unregister_device(pdev);
- 	return -EBUSY;
- 	};
- 
- if ((camnr = newcamera()) < 0)
- 	{
- 	parport_release(pdev);
- 	parport_unregister_device(pdev);
  	return -EBUSY;
  	};
  
! camera[camnr]->pdev = pdev;
! camera[camnr]->port = port;
! camera[camnr]->state = CPIA_FORWARD;
! camera[camnr]->camstate = CPIA_PHASE_idle;
! 
  /* detect the thing */
  
! parport_write_econtrol(port,PARPORT_MODE_PCECR);
! parport_pc_disable_irq(port);
  
  return 0; // success
  };
--- 259,286 ----
  
  int if_Open(int minor)
  {
! if(minor >= MAXCAMS || camera[minor] == NULL)
  	{
! 	LOG("Trying to open non-existent camera[%d]\n",minor);
  	return -ENXIO;
  	};
  
! if(camera[minor]->open_count > 0)
  	{
! 	return -EBUSY;
  	}
  
! if (parport_claim(camera[minor]->pdev))
  	{
  	LOG("failed to claim the port\n");
  	return -EBUSY;
  	};
  
! ++camera[minor]->open_count;
  /* detect the thing */
  
! parport_write_econtrol(camera[minor]->port,PARPORT_MODE_PCECR);
! parport_disable_irq(camera[minor]->port);
  
  return 0; // success
  };
***************
*** 325,358 ****
  
  int if_Close(int minor)
  {
! if (camera[minor])
  	{
! 	if (camera[minor]->port->irq > 0) parport_pc_disable_irq(camera[minor]->port);
  	parport_release(camera[minor]->pdev);
- 	parport_unregister_device(camera[minor]->pdev);
- 	freecam(minor);
  	}
! else	LOG("strange ... camera[%d] already NULL\n",minor);
  return 0;
  };
  
! int if_Init(void)
  {
! int i;
! for (i = 0;i < MAXCAMS;i++) camera[i] = NULL;
  return 0;
  };
  
  int if_Cleanup(void)
  {
  int i;
! for (i = 0;i < MAXCAMS;i++)
  	{
! 	if (camera[i])
  		{
  		LOG("You forgot to close minor %d, will do it for you\n",i);
  		if_Close(i);
  		};
  	};
  return 0;
  };
--- 293,454 ----
  
  int if_Close(int minor)
  {
! if(--camera[minor]->open_count == 0)
  	{
! 	del_timer(&camera[minor]->q_timer);
! 	if (camera[minor]->port->irq > 0) parport_disable_irq(camera[minor]->port);
  	parport_release(camera[minor]->pdev);
  	}
! else LOG("Multiply opened camera[%d]\n", minor);
  return 0;
  };
  
! int ppcpia_register(int minor, struct parport *port)
  {
! struct pardevice *pdev = NULL;
! 
! if (!(port->modes & PARPORT_MODE_PCECP))
! 	{
! 	LOG("port is not ECP capable\n");
! 	return -ENXIO;
! 	};
! 
! pdev = parport_register_device(port,"ppcpia",NULL,NULL,pp_irq_handler,0,camera[minor]);
! 
! if (!pdev)
!         {
!         LOG("failed to parport_register_device\n");
!         return -ENXIO;
!         }
! 
! camera[minor] = kmalloc(sizeof(struct cpia_entry),GFP_KERNEL);
! if(camera[minor] == NULL) {
!      LOG("kmalloc failed\n");
!      return -ENOMEM;
! }
! camera[minor]->pdev = pdev;
! camera[minor]->port = port;
! camera[minor]->state = CPIA_FORWARD;
! camera[minor]->camstate = CPIA_PHASE_idle;
! camera[minor]->q_wait = NULL;
! init_timer(&camera[minor]->q_timer);
! camera[minor]->open_count = 0;
! 
! return 0; // success
! }
! 
! int if_Init(char *str, int *ints)
! {
! struct parport *port;
! int i, count=0;
! 
! #ifdef MODULE
! if (parport[0]) {
! 	/* The user gave some parameters.  Let's see what they were.  */
! 	if (!strncmp(parport[0], "auto", 4))
! 		parport_nr[0] = PPCPIA_PARPORT_AUTO;
! 	else {
! 		int n;
! 		for (n = 0; n < MAXCAMS && parport[n]; n++) {
! 			if (!strncmp(parport[n], "none", 4))
! 				parport_nr[n] = PPCPIA_PARPORT_NONE;
! 			else {
! 				char *ep;
! 				unsigned long r = simple_strtoul(parport[n], &ep, 0);
! 				if (ep != parport[n]) 
! 					parport_nr[n] = r;
! 				else {
! 					LOG("bad port specifier `%s'\n", parport[n]);
! 					return -ENODEV;
! 				}
! 			}
! 		}
! 	}
! }
! 
! #if defined(CONFIG_KMOD) && defined(CONFIG_PNP_PARPORT_MODULE)
! request_module("parport_probe");
! #endif /* CONFIG_KMOD */
! 
! #else /* !MODULE */
! 
! if (!str) {
! 	if (ints[0] == 0 || ints[1] == 0) {
! 		/* disable driver on "ppcpia=" or "ppcpia=0" */
! 		parport_nr[0] = PPCPIA_PARPORT_OFF;
! 	}
! } else if (!strncmp(str, "parport", 7)) {
! 	int n = simple_strtoul(str+7, NULL, 10);
! 	if (parport_ptr < MAXCAMS)
! 		parport_nr[parport_ptr++] = n;
! 	else
! 		LOG("too many ports, %s ignored.\n", str);
! } else if (!strcmp(str, "auto")) {
! 	parport_nr[0] = PPCPIA_PARPORT_AUTO;
! } else if (!strcmp(str, "none")) {
! 	parport_nr[parport_ptr++] = PPCPIA_PARPORT_NONE;
! }
! 
! #endif /* !MODULE */
! 
! switch (parport_nr[0])
! {
! case PPCPIA_PARPORT_OFF:
! 	return 0;
! 
! case PPCPIA_PARPORT_UNSPEC:
! case PPCPIA_PARPORT_AUTO:
! 	for (port = parport_enumerate(); port; port = port->next) {
! 
! #if defined(CONFIG_PNP_PARPORT) || \
!     (defined(MODULE) && defined(CONFIG_PNP_PARPORT_MODULE))
! 		if(port->probe_info.class != PARPORT_CLASS_MEDIA ||
! 		   port->probe_info.cmdset == NULL ||
! 		   strncmp(port->probe_info.cmdset, "CPIA_1", 6) != 0)
! 			{
! 			continue;
! 			}
! #endif /* CONFIG_PNP_PARPORT || CONFIG_PNP_PARPORT_MODULE */
! 
! 		if (!ppcpia_register(count, port))
! 			if (++count == MAXCAMS)
! 				break;
! 	}
! 	break;
! 
! default:
! 	for (i = 0; i < MAXCAMS; i++) {
! 		for (port = parport_enumerate(); port; 
! 		     port = port->next) {
! 			if (port->number == parport_nr[i]) {
! 				if (!ppcpia_register(i, port))
! 					count++;
! 				break;
! 			}
! 		}
! 	}
! 	break;
! }
! 
! if(count == 0) {
! 	LOG("No cameras found\n");
! 	return -ENODEV;
! }
  return 0;
  };
  
  int if_Cleanup(void)
  {
  int i;
! for (i = 0;camera[i] != NULL && i < MAXCAMS;i++)
  	{
! 	if (camera[i]->open_count > 0)
  		{
  		LOG("You forgot to close minor %d, will do it for you\n",i);
  		if_Close(i);
  		};
+ 	parport_unregister_device(camera[i]->pdev);
+ 	kfree(camera[i]);
  	};
  return 0;
  };
diff -c -r cpia.old/module/interface_pp_low.c cpia/module/interface_pp_low.c
*** cpia.old/module/interface_pp_low.c	Tue Jun 29 03:13:14 1999
--- cpia/module/interface_pp_low.c	Tue Aug 31 15:54:25 1999
***************
*** 26,42 ****
  
  #define WHILE_OUT_TIMEOUT 10
  
! #define WHILE_OUT(thisthing)\
! {\
! if (thisthing)\
! 	{\
! 	unsigned long startjif = jiffies;\
! 	while ((thisthing)&&((jiffies-startjif)<WHILE_OUT_TIMEOUT));\
! 	if (!((jiffies-startjif)<WHILE_OUT_TIMEOUT))\
! 		{LOG("WhileoutError at line waited %ld\n",jiffies-startjif);\
! 		goto WhileoutError;};\
! 	};\
! };\
  
  int my_wait_peripheral(struct parport *port,int mask,int result)
  {
--- 26,76 ----
  
  #define WHILE_OUT_TIMEOUT 10
  
! void
! do_nothing(unsigned long ptr)
! {
! struct cpia_entry *cpia = (struct cpia_entry *)ptr;
! if(  cpia->q_wait != NULL )
!       {
!       wake_up_interruptible(&cpia->q_wait);
!       }
! return;
! }
! 
! int
! while_out(struct cpia_entry *cpia)
! {
! struct parport *port = cpia->port;
! unsigned long endjif;
! int i, j, is_sig=0;
! 
! if( GetECRMasked(port,ECR_full) ) return 1;
! 
! cpia->q_timer.function=do_nothing;
! cpia->q_timer.data=(unsigned long)cpia;
! 
! cpia->q_wait=NULL;
! for( j=0; j<WHILE_OUT_TIMEOUT; j++ )
! 	{
! 	endjif = jiffies+1;
! 	cpia->q_timer.expires=endjif;
! 	add_timer(&cpia->q_timer);
! 	interruptible_sleep_on(&cpia->q_wait);
! 	for ( i=0; i<_NSIG_WORDS && !is_sig; i++) /* ??? */
! 	  is_sig = current->signal.sig[i] &
! 	    ~current->blocked.sig[i];
! 	if (is_sig)
! 	  {
! 	  return 0;
! 	  }
! 	if( GetECRMasked(port,ECR_full) )
! 	      {
! 	      return 1;
! 	      }
! 	}
! LOG("WhileoutError at line waited %d\n",WHILE_OUT_TIMEOUT);
! return 0;
! }
  
  int my_wait_peripheral(struct parport *port,int mask,int result)
  {
***************
*** 327,333 ****
  
  while((((bytes-readbytes)/ECP_FIFO_SIZE) > 0)&&(endseen<4)) //at least 1 full fifo to do ?
  	{
! 	WHILE_OUT(!GetECRMasked(port,ECR_full)); //wait for FIFO to be full
  	for(j = 0;j < ECP_FIFO_SIZE;j++ )
  		{
  		*buf = parport_read_fifo(port);
--- 361,370 ----
  
  while((((bytes-readbytes)/ECP_FIFO_SIZE) > 0)&&(endseen<4)) //at least 1 full fifo to do ?
  	{
!         if( while_out(cpia)==0 )
!                 {
!                         goto WhileoutError;
!                 }
  	for(j = 0;j < ECP_FIFO_SIZE;j++ )
  		{
  		*buf = parport_read_fifo(port);
diff -c -r cpia.old/module/module.c cpia/module/module.c
*** cpia.old/module/module.c	Thu May 13 14:14:33 1999
--- cpia/module/module.c	Tue Aug 31 21:54:13 1999
***************
*** 1,12 ****
--- 1,17 ----
  // (C) 1999 Bas Huisman <bhuism@cs.utwente.nl>
  
  #include <linux/module.h>
+ #include <linux/init.h>
  #include <linux/wrapper.h>
  #include <linux/fs.h>
  
  #include "interface.h"
  #include "debug.h"
  
+ MODULE_AUTHOR("Bas Huisman <bhuism@cs.utwente.nl>");
+ MODULE_DESCRIPTION("Driver for Vision CPiA based parallel port cameras");
+ MODULE_SUPPORTED_DEVICE("cpia");
+ 
  #define CPIA_MAJOR		63
  #define CPIA_MODULE_NAME	"ppcpia"
  
***************
*** 19,48 ****
  int pp_cpia_open(struct inode *inode, struct file *file) // open()
  {
  if (if_Open(MINOR(inode->i_rdev))) return -1;
  MOD_INC_USE_COUNT;
  return 0;
  };
  
  int pp_cpia_close(struct inode *inode, struct file *file) // close() must never fail
  {
  MOD_DEC_USE_COUNT;
  return if_Close(MINOR(inode->i_rdev));
  };
  
  ssize_t pp_cpia_read(struct file *file,char *buffer,size_t length, loff_t *lofft)
  {
- int minor = 0; //fixme
  if (!buffer) return -EINVAL;
! return if_StreamRead(minor,buffer,length);
  };
  
  int pp_cpia_ioctl(struct inode *inode,struct file *file,unsigned int ioctlnr,unsigned long arg)
  {
! int minor = 0; //fixme
! return if_TransferMsg(minor,ioctlnr,(struct ioctlstruct *)arg);
  };
  
! struct file_operations cpia_fops =
  	{
  	NULL,			/* llseek */
  	pp_cpia_read,		/* read */
--- 24,56 ----
  int pp_cpia_open(struct inode *inode, struct file *file) // open()
  {
  if (if_Open(MINOR(inode->i_rdev))) return -1;
+ file->private_data = (void *)MINOR(inode->i_rdev);
+ #ifdef MODULE
  MOD_INC_USE_COUNT;
+ #endif
  return 0;
  };
  
  int pp_cpia_close(struct inode *inode, struct file *file) // close() must never fail
  {
+ #ifdef MODULE
  MOD_DEC_USE_COUNT;
+ #endif
  return if_Close(MINOR(inode->i_rdev));
  };
  
  ssize_t pp_cpia_read(struct file *file,char *buffer,size_t length, loff_t *lofft)
  {
  if (!buffer) return -EINVAL;
! return if_StreamRead((int)file->private_data,buffer,length);
  };
  
  int pp_cpia_ioctl(struct inode *inode,struct file *file,unsigned int ioctlnr,unsigned long arg)
  {
! return if_TransferMsg(MINOR(inode->i_rdev),ioctlnr,(struct ioctlstruct *)arg);
  };
  
! static struct file_operations cpia_fops =
  	{
  	NULL,			/* llseek */
  	pp_cpia_read,		/* read */
***************
*** 67,75 ****
  //
  // ***************************************************************************
  
  int init_module(void)
  {
! if (if_Init()) return -1;
  if (module_register_chrdev(CPIA_MAJOR,CPIA_MODULE_NAME,&cpia_fops))
  	{
  	LOG("unable to get major %d\n",CPIA_MAJOR);
--- 75,84 ----
  //
  // ***************************************************************************
  
+ #ifdef MODULE
  int init_module(void)
  {
! if (if_Init(NULL, NULL)) return -1;
  if (module_register_chrdev(CPIA_MAJOR,CPIA_MODULE_NAME,&cpia_fops))
  	{
  	LOG("unable to get major %d\n",CPIA_MAJOR);
***************
*** 85,87 ****
--- 94,105 ----
  if (module_unregister_chrdev(CPIA_MAJOR,CPIA_MODULE_NAME) < 0)
  	LOG("module_unregister_chrdev failed\n"); 
  };
+ 
+ #else
+ 
+ __initfunc(void cpia_setup(char *str, int *ints))
+ {
+ if_Init(str, ints));
+ };
+ 
+ #endif

--0-1804289383-936156046=:1986--
-----------------------------------------------------------------------------
To unsubscribe from this mailinglist, send the line "unsubscribe vision-webcam" in the
body of a message to "majordomo@errors.no".