Patching v0-2 with two patches
Jacob Nikom
nikom@merl.com
Tue, 31 Aug 1999 18:38:18 -0400
Hi Scott,
I tried to apply the combined patch agaist Bas' cpia-0.2 few times but
failed. The size of the patch I got is 14,423 bytes. Is it correct
value?
May it is simplier to place the patched (full) version into tar, zip it
and
send to archive?
Regards,
Jacob
sbertin@mindspring.com wrote:
>
> On 31 Aug, Bas Rijniersce wrote:
> > Hmmm,
> >
> > I should have known it, my C isn't good enough to merge even two patches
> > ;-)
> > If i apply Scott's big patch first and the Peter's patch there are only
> > a few rejects:
> > 1 out of 1 hunk FAILED -- saving rejects to cpia/module/cpia_entry.h.rej
> > 2 out of 2 hunks FAILED -- saving rejects to
> > cpia/module/interface_pp.c.rej
> >
> > The first one is so easy that even I can cut/paste them together. The
> > second, the interface_pp.c file, has undergone quite a bit of rewriting.
> > Enough to throw me off track. Scott, maybe you could fit them in??? It's
> > only a few lines that you can place in the right spot very easily I
> > think..
>
> Here is a combined patch against cpia-0.2. It also has a small
> improvement to my patch.
>
> Scott J. Bertin
> sbertin@mindspring.com
>
> ------------------------------------------------------------------------
> diff -c -r cpia.old/module/Makefile cpia/module/Makefile
> *** cpia.old/module/Makefile Mon Aug 30 18:55:15 1999
> --- cpia/module/Makefile Mon Aug 30 18:31:07 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 =
> ***************
> *** 11,18 ****
> PPCUS = module.o interface_pp.o interface_pp_low.o
> PPV4L2 = v4l2.o interface_pp.o interface_pp_low.o
>
> ! all: .depend ppcuscpia.o
> ! #ppv4l2cpia.o
>
> .c.o:
> $(CC) -c $(CFLAGS) $<
> --- 11,17 ----
> PPCUS = module.o interface_pp.o interface_pp_low.o
> PPV4L2 = v4l2.o interface_pp.o interface_pp_low.o
>
> ! all: .depend ppcuscpia.o ppv4l2cpia.o
>
> .c.o:
> $(CC) -c $(CFLAGS) $<
> diff -c -r cpia.old/module/cpia_entry.h cpia/module/cpia_entry.h
> *** cpia.old/module/cpia_entry.h Mon Aug 30 18:55:15 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_pp.c cpia/module/interface_pp.c
> *** cpia.old/module/interface_pp.c Mon Aug 30 18:55:15 1999
> --- cpia/module/interface_pp.c Mon Aug 30 19:00:34 1999
> ***************
> *** 1,5 ****
> --- 1,8 ----
>
> // (C) 1999 Bas Huisman <bhuism@cs.utwente.nl>
> + // and Scott J. Bertin <sbertin@mindspring.com>
> +
> + #include <linux/config.h>
>
> #include <linux/parport.h>
>
> ***************
> *** 9,18 ****
> #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",
> --- 12,25 ----
> #include "procs.h"
> #include "debug.h"
>
> + #ifdef CONFIG_KMOD
> + #include <linux/kmod.h>
> + #endif
> +
> #define MAXCAMS 4
> #define PACKET_LENGTH 8
>
> ! struct cpia_entry *camera;
>
> char camstatesstr[12][40] = {
> "CPIA_PHASE_idle",
> ***************
> *** 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
> //
> // ***************************************************************************
> --- 35,40 ----
> ***************
> *** 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]);
> };
> };
>
> --- 89,101 ----
> 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;
> };
>
> --- 114,123 ----
> 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;
> };
>
> ***************
> *** 168,176 ****
> u8 cmd[PACKET_LENGTH] = {0,0,0,0,0,0,0,0};
> struct ioctlstruct *ioctlstr = (struct ioctlstruct *)iostru;
> int databytes;
> ! struct cpia_entry *cpia = camera[minor];
> !
> ! if (!camera[minor]) return -1;
>
> if ((ioctlnr<0)||(ioctlnr >= ((sizeof(ioctl2proc))/sizeof(ioctl2proc[0]))))
> {
> --- 136,142 ----
> u8 cmd[PACKET_LENGTH] = {0,0,0,0,0,0,0,0};
> struct ioctlstruct *ioctlstr = (struct ioctlstruct *)iostru;
> int databytes;
> ! struct cpia_entry *cpia = &camera[minor];
>
> if ((ioctlnr<0)||(ioctlnr >= ((sizeof(ioctl2proc))/sizeof(ioctl2proc[0]))))
> {
> ***************
> *** 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
> };
> --- 221,249 ----
>
> int if_Open(int minor)
> {
> ! if(minor >= MAXCAMS || camera[minor].pdev == 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_pc_disable_irq(camera[minor].port);
> ! init_timer(&camera[minor].q_timer);
>
> 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;
> };
> --- 256,350 ----
>
> int if_Close(int minor)
> {
> ! if(--camera[minor].open_count == 0)
> {
> ! del_timer(&camera[minor].q_timer);
> ! if (camera[minor].port->irq > 0) parport_pc_disable_irq(camera[minor].port);
> ! parport_release(camera[minor].pdev);
> }
> ! else LOG("Multiply opened camera[%d]\n", minor);
> return 0;
> };
>
> + int cpia_register(int minor, struct parport *port)
> + {
> + struct pardevice *pdev = NULL;
> +
> + #ifdef CONFIG_PNP_PARPORT_MODULE
> + #ifdef CONFIG_KMOD
> + request_module("parport_probe");
> + #endif /* CONFIG_KMOD */
> + if(port->probe_info.class != PARPORT_CLASS_MEDIA ||
> + port->probe_info.cmdset == NULL ||
> + strncmp(port->probe_info.cmdset, "CPIA_1", 6) != 0)
> + {
> + return -ENXIO;
> + }
> + #endif /* CONFIG_PNP_PARPORT_MODULE */
> +
> + pdev = parport_register_device(port,"cpia",NULL,NULL,pp_irq_handler,0,&camera[minor]);
> +
> + if (!pdev)
> + {
> + LOG("failed to parport_register_device\n");
> + return -ENXIO;
> + }
> +
> + if (!(port->modes & PARPORT_MODE_PCECP))
> + {
> + LOG("port is not ECP capable\n");
> + parport_unregister_device(pdev);
> + return -ENXIO;
> + };
> +
> + camera[minor].pdev = pdev;
> + camera[minor].port = port;
> + camera[minor].state = CPIA_FORWARD;
> + camera[minor].camstate = CPIA_PHASE_idle;
> + camera[minor].q_wait = NULL;
> + camera[minor].open_count = 0;
> +
> + return 0; // success
> + }
> +
> int if_Init(void)
> {
> ! struct parport *port;
> ! int i=0;
> ! camera = kmalloc(MAXCAMS*sizeof(struct cpia_entry),GFP_KERNEL);
> ! for (port = parport_enumerate(); port; port = port->next) {
> ! if (!cpia_register(i, port))
> ! if (++i == MAXCAMS)
> ! break;
> ! }
> ! if(i == 0) {
> ! LOG("No cameras found\n");
> ! kfree(camera);
> ! return -ENODEV;
> ! }
> ! while (i < MAXCAMS)
> ! {
> ! camera[i].pdev = NULL;
> ! camera[i].port = NULL;
> ! camera[i].q_wait = NULL;
> ! camera[i].open_count = 0;
> ! ++i;
> ! };
> return 0;
> };
>
> int if_Cleanup(void)
> {
> int i;
> ! for (i = 0;camera[i].pdev != 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);
> 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 Mon Aug 30 18:55:15 1999
> --- cpia/module/interface_pp_low.c Mon Aug 30 18:59:00 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,73 ----
>
> #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, is_sig=0;
> !
> ! if( GetECRMasked(port,ECR_full) ) return 1;
> !
> ! cpia->q_timer.function=do_nothing;
> ! cpia->q_timer.data=(unsigned long)cpia;
> ! endjif = jiffies+WHILE_OUT_TIMEOUT;
> ! cpia->q_timer.expires=endjif;
> !
> ! cpia->q_wait=NULL;
> ! 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) )
> ! {
> ! LOG("WhileoutError at line waited %d\n",WHILE_OUT_TIMEOUT);
> ! return 0;
> ! }
> ! return 1;
> ! }
>
> 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);
> --- 358,367 ----
>
> 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 Sat Aug 28 21:05:34 1999
> ***************
> *** 19,24 ****
> --- 19,25 ----
> 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);
> MOD_INC_USE_COUNT;
> return 0;
> };
> ***************
> *** 31,45 ****
>
> 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 =
> --- 32,44 ----
>
> 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);
> };
>
> struct file_operations cpia_fops =
-----------------------------------------------------------------------------
To unsubscribe from this mailinglist, send the line "unsubscribe vision-webcam" in the
body of a message to "majordomo@errors.no".