Commit 7b680613 authored by Nemosoft Unv's avatar Nemosoft Unv Committed by Greg Kroah-Hartman

[PATCH] USB: PWC 8.11

Attached are two patches, one for 2.4.21 and 2.5.75 for the PWC driver. I
assume the 2.5.75 patch will go into 2.6.0-test* without problems (I hope
this driver can make it into the kernel before the 'real' 2.6.0).

 From the ChangeLog:

* 20 dev_hints (per request)
* Hot unplugging should be better, no more dangling pointers or memory leaks
* Added reserved Logitech webcam IDs
* Device now remembers size & fps between close()/open()
* Removed palette stuff altogether

I have two open issues, though: Oliver Neukem pointed out that I should
resubmit URBs in the 2.5. kernel even in case of USB errors, which I did.
However, I never got a patch so I'm not 100% if this is the solution that
he had in mind.

Second... I've been thinking long and hard about the problem of properly
deregistering the video device when the cam gets unplugged while it is in
use. Various schemes failed; immediately deregistering while in the
disconnect routine causes crashes because the videodev layer sets some
pointer to null but still uses it later. A deregister in close() causes
hangs because of locked mutexes...

My current implemententation is to set an errorflag in the disconnect
routine, then wait there (using schedule()) until close() is being called
(I assume the application will immediately close the device when it gets a
serious error). So far it doesn't crash :-)
parent df9e735b
/* Driver for Philips webcam
Functions that send various control messages to the webcam, including
video modes.
(C) 1999-2002 Nemosoft Unv. (webcam@smcc.demon.nl)
(C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -452,7 +452,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
pdev->view.x = width;
pdev->view.y = height;
pwc_set_image_buffer_size(pdev);
Trace(TRACE_SIZE, "Set viewport to %dx%d, image size is %dx%d, palette = %d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y, pdev->vpalette);
Trace(TRACE_SIZE, "Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y);
return 0;
}
......@@ -461,38 +461,8 @@ void pwc_set_image_buffer_size(struct pwc_device *pdev)
{
int factor, i, filler = 0;
switch(pdev->vpalette) {
case VIDEO_PALETTE_RGB32 | 0x80:
case VIDEO_PALETTE_RGB32:
factor = 16;
filler = 0;
break;
case VIDEO_PALETTE_RGB24 | 0x80:
case VIDEO_PALETTE_RGB24:
factor = 12;
filler = 0;
break;
case VIDEO_PALETTE_YUYV:
case VIDEO_PALETTE_YUV422:
factor = 8;
filler = 128;
break;
case VIDEO_PALETTE_YUV420:
case VIDEO_PALETTE_YUV420P:
factor = 6;
filler = 128;
break;
#if PWC_DEBUG
case VIDEO_PALETTE_RAW:
pdev->image.size = pdev->frame_size;
pdev->view.size = pdev->frame_size;
return;
break;
#endif
default:
factor = 0;
break;
}
/* Set sizes in bytes */
pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
......@@ -1355,7 +1325,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
{
struct pwc_probe *probe = arg;
strcpy(probe->name, pdev->vdev->name);
strcpy(probe->name, pdev->vdev.name);
probe->type = pdev->type;
break;
}
......
This diff is collapsed.
#ifndef PWC_IOCTL_H
#define PWC_IOCTL_H
/* (C) 2001-2002 Nemosoft Unv. webcam@smcc.demon.nl
/* (C) 2001-2003 Nemosoft Unv. webcam@smcc.demon.nl
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* Linux driver for Philips webcam
Various miscellaneous functions and tables.
(C) 1999-2002 Nemosoft Unv. (webcam@smcc.demon.nl)
(C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -81,6 +81,7 @@ void pwc_construct(struct pwc_device *pdev)
pdev->frame_header_size = 0;
pdev->frame_trailer_size = 0;
break;
case 720:
case 730:
case 740:
case 750:
......
/* Linux driver for Philips webcam
Decompression frontend.
(C) 1999-2002 Nemosoft Unv. (webcam@smcc.demon.nl)
(C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -98,14 +98,6 @@ int pwc_decompress(struct pwc_device *pdev)
if (!image)
return -EFAULT;
#if PWC_DEBUG
/* This is a quickie */
if (pdev->vpalette == VIDEO_PALETTE_RAW) {
memcpy(image, fbuf->data, pdev->frame_size);
return 0;
}
#endif
yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
if (pdev->vbandlength == 0) {
/* Uncompressed mode. We copy the data into the output buffer,
......@@ -113,8 +105,6 @@ int pwc_decompress(struct pwc_device *pdev)
size). Unfortunately we have to do a bit of byte stuffing
to get the desired output format/size.
*/
switch (pdev->vpalette) {
case VIDEO_PALETTE_YUV420P:
/*
* We do some byte shuffling here to go from the
* native format to YUV420P.
......@@ -149,11 +139,6 @@ int pwc_decompress(struct pwc_device *pdev)
else
dstu += (stride >> 1);
}
break;
default:
Err("Unsupported palette!");
break;
}
}
else {
/* Compressed; the decompressor routines will write the data
......
/* (C) 1999-2002 Nemosoft Unv. (webcam@smcc.demon.nl)
/* (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
/* (C) 1999-2002 Nemosoft Unv. (webcam@smcc.demon.nl)
/* (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -60,8 +60,8 @@
/* Version block */
#define PWC_MAJOR 8
#define PWC_MINOR 10
#define PWC_VERSION "8.10"
#define PWC_MINOR 11
#define PWC_VERSION "8.11"
#define PWC_NAME "pwc"
/* Turn certain features on/off */
......@@ -82,7 +82,7 @@
#define PWC_FRAME_SIZE (460800 + TOUCAM_HEADER_SIZE + TOUCAM_TRAILER_SIZE)
/* Absolute maximum number of buffers available for mmap() */
#define MAX_IMAGES 4
#define MAX_IMAGES 10
struct pwc_coord
{
......@@ -112,6 +112,7 @@ struct pwc_frame_buf
struct pwc_device
{
struct video_device vdev;
#ifdef PWC_MAGIC
int magic;
#endif
......@@ -120,22 +121,21 @@ struct pwc_device
int type; /* type of cam (645, 646, 675, 680, 690) */
int release; /* release number */
int unplugged; /* set when the plug is pulled */
int error_status; /* set when something goes wrong with the cam (unplugged, USB errors) */
int usb_init; /* set when the cam has been initialized over USB */
/*** Video data ***/
int vopen; /* flag */
struct video_device *vdev;
int vendpoint; /* video isoc endpoint */
int vcinterface; /* video control interface */
int valternate; /* alternate interface needed */
int vframes, vsize; /* frames-per-second & size (see PSZ_*) */
int vpalette; /* YUV */
int vframe_count; /* received frames */
int vframes_dumped; /* counter for dumped frames */
int vframes_error; /* frames received in error */
int vmax_packet_size; /* USB maxpacket size */
int vlast_packet_size; /* for frame synchronisation */
int visoc_errors; /* number of contiguous ISOC errors */
int vcompression; /* desired compression factor */
int vbandlength; /* compressed band length; 0 is uncompressed */
char vsnapshot; /* snapshot mode */
......@@ -196,7 +196,6 @@ struct pwc_device
/*** Misc. data ***/
wait_queue_head_t frameq; /* When waiting for a frame to finish... */
wait_queue_head_t remove_ok; /* When we got hot unplugged, we have to avoid a few race conditions */
#if PWC_INT_PIPE
void *usb_int_handler; /* for the interrupt endpoint */
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment