Commit 4afc05e5 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] cpia -maintainers update

parent 765af494
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* #define _CPIA_DEBUG_ define for verbose debug output */ /* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
/* #define _CPIA_DEBUG_ 1 */
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -1796,7 +1798,7 @@ static int do_command_extended(struct cam_data *cam, u16 command, ...@@ -1796,7 +1798,7 @@ static int do_command_extended(struct cam_data *cam, u16 command,
retval = cam->ops->transferCmd(cam->lowlevel_data, cmd, data); retval = cam->ops->transferCmd(cam->lowlevel_data, cmd, data);
if (retval) if (retval)
LOG("%x - failed\n", command); DBG("%x - failed\n", command);
return retval; return retval;
} }
...@@ -2174,7 +2176,7 @@ static int parse_picture(struct cam_data *cam, int size) ...@@ -2174,7 +2176,7 @@ static int parse_picture(struct cam_data *cam, int size)
} }
if (ll == 1) { if (ll == 1) {
if (*ibuf != EOL) { if (*ibuf != EOL) {
LOG("EOL not found giving up after %d/%d" DBG("EOL not found giving up after %d/%d"
" bytes\n", origsize-size, origsize); " bytes\n", origsize-size, origsize);
return -1; return -1;
} }
...@@ -3158,7 +3160,8 @@ static int reset_camera(struct cam_data *cam) ...@@ -3158,7 +3160,8 @@ static int reset_camera(struct cam_data *cam)
static void put_cam(struct cpia_camera_ops* ops) static void put_cam(struct cpia_camera_ops* ops)
{ {
module_put(ops->owner); if (ops->owner)
module_put(ops->owner);
} }
/* ------------------------- V4L interface --------------------- */ /* ------------------------- V4L interface --------------------- */
...@@ -3173,16 +3176,15 @@ static int cpia_open(struct inode *inode, struct file *file) ...@@ -3173,16 +3176,15 @@ static int cpia_open(struct inode *inode, struct file *file)
return -ENODEV; return -ENODEV;
} }
if (cam->open_count > 0) {
DBG("Camera already open\n");
return -EBUSY;
}
if (!try_module_get(cam->ops->owner)) if (!try_module_get(cam->ops->owner))
return -ENODEV; return -ENODEV;
down(&cam->busy_lock); down(&cam->busy_lock);
err = -EBUSY;
if (cam->open_count > 0) {
DBG("Camera already open\n");
goto oops;
}
err = -ENOMEM; err = -ENOMEM;
if (!cam->raw_image) { if (!cam->raw_image) {
cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE); cam->raw_image = rvmalloc(CPIA_MAX_IMAGE_SIZE);
...@@ -3206,10 +3208,11 @@ static int cpia_open(struct inode *inode, struct file *file) ...@@ -3206,10 +3208,11 @@ static int cpia_open(struct inode *inode, struct file *file)
cam->ops->close(cam->lowlevel_data); cam->ops->close(cam->lowlevel_data);
goto oops; goto oops;
} }
if(signal_pending(current))
return -EINTR;
err = -EINTR;
if(signal_pending(current))
goto oops;
/* Set ownership of /proc/cpia/videoX to current user */ /* Set ownership of /proc/cpia/videoX to current user */
if(cam->proc_entry) if(cam->proc_entry)
cam->proc_entry->uid = current->uid; cam->proc_entry->uid = current->uid;
...@@ -3451,6 +3454,14 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, ...@@ -3451,6 +3454,14 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
cam->params.colourParams.contrast = 80; cam->params.colourParams.contrast = 80;
} }
/* Adjust flicker control if necessary */
if(cam->params.flickerControl.allowableOverExposure < 0)
cam->params.flickerControl.allowableOverExposure =
-find_over_exposure(cam->params.colourParams.brightness);
if(cam->params.flickerControl.flickerMode != 0)
cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
/* queue command to update camera */ /* queue command to update camera */
cam->cmd_queue |= COMMAND_SETCOLOURPARAMS; cam->cmd_queue |= COMMAND_SETCOLOURPARAMS;
up(&cam->param_lock); up(&cam->param_lock);
...@@ -3600,7 +3611,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, ...@@ -3600,7 +3611,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
{ {
int *frame = arg; int *frame = arg;
//DBG("VIDIOCSYNC: %d\n", frame); //DBG("VIDIOCSYNC: %d\n", *frame);
if (*frame<0 || *frame >= FRAME_NUM) { if (*frame<0 || *frame >= FRAME_NUM) {
retval = -EINVAL; retval = -EINVAL;
...@@ -3628,52 +3639,53 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, ...@@ -3628,52 +3639,53 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
} }
case VIDIOCGCAPTURE: case VIDIOCGCAPTURE:
{
struct video_capture *vc = arg;
DBG("VIDIOCGCAPTURE\n"); DBG("VIDIOCGCAPTURE\n");
if (copy_to_user(arg, &cam->vc, sizeof(struct video_capture)))
retval = -EFAULT; *vc = cam->vc;
break; break;
}
case VIDIOCSCAPTURE: case VIDIOCSCAPTURE:
{ {
struct video_capture vc; struct video_capture *vc = arg;
DBG("VIDIOCSCAPTURE\n"); DBG("VIDIOCSCAPTURE\n");
if (copy_from_user(&vc, arg, sizeof(vc))) {
retval = -EFAULT;
break;
}
if (vc.decimation != 0) { /* How should this be used? */ if (vc->decimation != 0) { /* How should this be used? */
retval = -EINVAL; retval = -EINVAL;
break; break;
} }
if (vc.flags != 0) { /* Even/odd grab not supported */ if (vc->flags != 0) { /* Even/odd grab not supported */
retval = -EINVAL; retval = -EINVAL;
break; break;
} }
/* Clip to the resolution we can set for the ROI /* Clip to the resolution we can set for the ROI
(every 8 columns and 4 rows) */ (every 8 columns and 4 rows) */
vc.x = vc.x & ~(__u32)7; vc->x = vc->x & ~(__u32)7;
vc.y = vc.y & ~(__u32)3; vc->y = vc->y & ~(__u32)3;
vc.width = vc.width & ~(__u32)7; vc->width = vc->width & ~(__u32)7;
vc.height = vc.height & ~(__u32)3; vc->height = vc->height & ~(__u32)3;
if(vc.width == 0 || vc.height == 0 || if(vc->width == 0 || vc->height == 0 ||
vc.x + vc.width > cam->vw.width || vc->x + vc->width > cam->vw.width ||
vc.y + vc.height > cam->vw.height) { vc->y + vc->height > cam->vw.height) {
retval = -EINVAL; retval = -EINVAL;
break; break;
} }
DBG("%d,%d/%dx%d\n", vc.x,vc.y,vc.width, vc.height); DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height);
down(&cam->param_lock); down(&cam->param_lock);
cam->vc.x = vc.x; cam->vc.x = vc->x;
cam->vc.y = vc.y; cam->vc.y = vc->y;
cam->vc.width = vc.width; cam->vc.width = vc->width;
cam->vc.height = vc.height; cam->vc.height = vc->height;
set_vw_size(cam); set_vw_size(cam);
cam->cmd_queue |= COMMAND_SETFORMAT; cam->cmd_queue |= COMMAND_SETFORMAT;
...@@ -3688,16 +3700,20 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file, ...@@ -3688,16 +3700,20 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
case VIDIOCGUNIT: case VIDIOCGUNIT:
{ {
struct video_unit vu; struct video_unit *vu = arg;
vu.video = cam->vdev.minor;
vu.vbi = VIDEO_NO_UNIT; DBG("VIDIOCGUNIT\n");
vu.radio = VIDEO_NO_UNIT;
vu.audio = VIDEO_NO_UNIT; vu->video = cam->vdev.minor;
vu.teletext = VIDEO_NO_UNIT; vu->vbi = VIDEO_NO_UNIT;
vu->radio = VIDEO_NO_UNIT;
vu->audio = VIDEO_NO_UNIT;
vu->teletext = VIDEO_NO_UNIT;
break; break;
} }
/* pointless to implement overlay with this camera */ /* pointless to implement overlay with this camera */
case VIDIOCCAPTURE: case VIDIOCCAPTURE:
case VIDIOCGFBUF: case VIDIOCGFBUF:
...@@ -3728,12 +3744,13 @@ static int cpia_ioctl(struct inode *inode, struct file *file, ...@@ -3728,12 +3744,13 @@ static int cpia_ioctl(struct inode *inode, struct file *file,
return video_usercopy(inode, file, cmd, arg, cpia_do_ioctl); return video_usercopy(inode, file, cmd, arg, cpia_do_ioctl);
} }
/* FIXME */ /* FIXME */
static int cpia_mmap(struct file *file, struct vm_area_struct *vma) static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
{ {
struct video_device *dev = file->private_data; struct video_device *dev = file->private_data;
unsigned long start = vma->vm_start; unsigned long start = vma->vm_start;
unsigned long size = vma->vm_end-vma->vm_start; unsigned long size = vma->vm_end - vma->vm_start;
unsigned long page, pos; unsigned long page, pos;
struct cam_data *cam = dev->priv; struct cam_data *cam = dev->priv;
int retval; int retval;
...@@ -3956,9 +3973,6 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve ...@@ -3956,9 +3973,6 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve
printk(KERN_DEBUG "video_register_device failed\n"); printk(KERN_DEBUG "video_register_device failed\n");
return NULL; return NULL;
} }
#ifdef CONFIG_PROC_FS
create_proc_cpia_cam(camera);
#endif
/* get version information from camera: open/reset/close */ /* get version information from camera: open/reset/close */
...@@ -3975,6 +3989,10 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve ...@@ -3975,6 +3989,10 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve
/* close cpia */ /* close cpia */
camera->ops->close(camera->lowlevel_data); camera->ops->close(camera->lowlevel_data);
#ifdef CONFIG_PROC_FS
create_proc_cpia_cam(camera);
#endif
printk(KERN_INFO " CPiA Version: %d.%02d (%d.%d)\n", printk(KERN_INFO " CPiA Version: %d.%02d (%d.%d)\n",
camera->params.version.firmwareVersion, camera->params.version.firmwareVersion,
camera->params.version.firmwareRevision, camera->params.version.firmwareRevision,
...@@ -3997,6 +4015,7 @@ void cpia_unregister_camera(struct cam_data *cam) ...@@ -3997,6 +4015,7 @@ void cpia_unregister_camera(struct cam_data *cam)
DBG("unregistering video\n"); DBG("unregistering video\n");
video_unregister_device(&cam->vdev); video_unregister_device(&cam->vdev);
if (cam->open_count) { if (cam->open_count) {
put_cam(cam->ops);
DBG("camera open -- setting ops to NULL\n"); DBG("camera open -- setting ops to NULL\n");
cam->ops = NULL; cam->ops = NULL;
} }
...@@ -4019,9 +4038,6 @@ static int __init cpia_init(void) ...@@ -4019,9 +4038,6 @@ static int __init cpia_init(void)
proc_cpia_create(); proc_cpia_create();
#endif #endif
#ifdef CONFIG_VIDEO_CPIA_PP
cpia_pp_init();
#endif
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
#ifdef CONFIG_VIDEO_CPIA_PP_MODULE #ifdef CONFIG_VIDEO_CPIA_PP_MODULE
request_module("cpia_pp"); request_module("cpia_pp");
...@@ -4031,6 +4047,10 @@ static int __init cpia_init(void) ...@@ -4031,6 +4047,10 @@ static int __init cpia_init(void)
request_module("cpia_usb"); request_module("cpia_usb");
#endif #endif
#endif /* CONFIG_KMOD */ #endif /* CONFIG_KMOD */
#ifdef CONFIG_VIDEO_CPIA_PP
cpia_pp_init();
#endif
#ifdef CONFIG_VIDEO_CPIA_USB #ifdef CONFIG_VIDEO_CPIA_USB
cpia_usb_init(); cpia_usb_init();
#endif #endif
......
...@@ -27,12 +27,16 @@ ...@@ -27,12 +27,16 @@
*/ */
#define CPIA_MAJ_VER 1 #define CPIA_MAJ_VER 1
#define CPIA_MIN_VER 2 #define CPIA_MIN_VER 2
#define CPIA_PATCH_VER 2 #define CPIA_PATCH_VER 3
#define CPIA_PP_MAJ_VER 1 #define CPIA_PP_MAJ_VER CPIA_MAJ_VER
#define CPIA_PP_MIN_VER 2 #define CPIA_PP_MIN_VER CPIA_MIN_VER
#define CPIA_PP_PATCH_VER 2 #define CPIA_PP_PATCH_VER CPIA_PATCH_VER
#define CPIA_USB_MAJ_VER CPIA_MAJ_VER
#define CPIA_USB_MIN_VER CPIA_MIN_VER
#define CPIA_USB_PATCH_VER CPIA_PATCH_VER
#define CPIA_MAX_FRAME_SIZE_UNALIGNED (352 * 288 * 4) /* CIF at RGB32 */ #define CPIA_MAX_FRAME_SIZE_UNALIGNED (352 * 288 * 4) /* CIF at RGB32 */
#define CPIA_MAX_FRAME_SIZE ((CPIA_MAX_FRAME_SIZE_UNALIGNED + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) /* align above to PAGE_SIZE */ #define CPIA_MAX_FRAME_SIZE ((CPIA_MAX_FRAME_SIZE_UNALIGNED + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) /* align above to PAGE_SIZE */
......
This diff is collapsed.
...@@ -21,11 +21,13 @@ ...@@ -21,11 +21,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
/* #define _CPIA_DEBUG_ 1 */
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/sched.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -105,7 +107,7 @@ static struct cpia_camera_ops cpia_usb_ops = { ...@@ -105,7 +107,7 @@ static struct cpia_camera_ops cpia_usb_ops = {
}; };
static LIST_HEAD(cam_list); static LIST_HEAD(cam_list);
static spinlock_t cam_list_lock_usb = SPIN_LOCK_UNLOCKED; static spinlock_t cam_list_lock_usb;
static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs) static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
{ {
...@@ -464,12 +466,14 @@ static int cpia_usb_close(void *privdata) ...@@ -464,12 +466,14 @@ static int cpia_usb_close(void *privdata)
{ {
struct usb_cpia *ucpia = (struct usb_cpia *) privdata; struct usb_cpia *ucpia = (struct usb_cpia *) privdata;
ucpia->open = 0; if(!ucpia)
return -ENODEV;
cpia_usb_free_resources(ucpia, 1); ucpia->open = 0;
if (!ucpia->present) /* ucpia->present = 0 protects against trying to reset the
kfree(ucpia); * alt setting if camera is physically disconnected while open */
cpia_usb_free_resources(ucpia, ucpia->present);
return 0; return 0;
} }
...@@ -565,7 +569,7 @@ static int cpia_probe(struct usb_interface *intf, ...@@ -565,7 +569,7 @@ static int cpia_probe(struct usb_interface *intf,
vfree(ucpia->buffers[0]); vfree(ucpia->buffers[0]);
ucpia->buffers[0] = NULL; ucpia->buffers[0] = NULL;
fail_alloc_0: fail_alloc_0:
kfree(ucpia);
return -EIO; return -EIO;
} }
...@@ -588,9 +592,6 @@ static struct usb_driver cpia_driver = { ...@@ -588,9 +592,6 @@ static struct usb_driver cpia_driver = {
.id_table = cpia_id_table, .id_table = cpia_id_table,
}; };
/* don't use dev, it may be NULL! (see usb_cpia_cleanup) */
/* _disconnect from usb_cpia_cleanup is not necessary since usb_deregister */
/* will do it for us as well as passing a udev structure - jerdfelt */
static void cpia_disconnect(struct usb_interface *intf) static void cpia_disconnect(struct usb_interface *intf)
{ {
struct cam_data *cam = usb_get_intfdata(intf); struct cam_data *cam = usb_get_intfdata(intf);
...@@ -606,12 +607,11 @@ static void cpia_disconnect(struct usb_interface *intf) ...@@ -606,12 +607,11 @@ static void cpia_disconnect(struct usb_interface *intf)
list_del(&cam->cam_data_list); list_del(&cam->cam_data_list);
spin_unlock( &cam_list_lock_usb ); spin_unlock( &cam_list_lock_usb );
/* Don't even try to reset the altsetting if we're disconnected */
cpia_usb_free_resources(ucpia, 0);
ucpia->present = 0; ucpia->present = 0;
cpia_unregister_camera(cam); cpia_unregister_camera(cam);
if(ucpia->open)
cpia_usb_close(cam->lowlevel_data);
ucpia->curbuff->status = FRAME_ERROR; ucpia->curbuff->status = FRAME_ERROR;
...@@ -639,29 +639,25 @@ static void cpia_disconnect(struct usb_interface *intf) ...@@ -639,29 +639,25 @@ static void cpia_disconnect(struct usb_interface *intf)
ucpia->buffers[0] = NULL; ucpia->buffers[0] = NULL;
} }
if (!ucpia->open) { cam->lowlevel_data = NULL;
kfree(ucpia); kfree(ucpia);
cam->lowlevel_data = NULL;
}
} }
static int __init usb_cpia_init(void) static int __init usb_cpia_init(void)
{ {
printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER);
spin_lock_init(&cam_list_lock_usb);
return usb_register(&cpia_driver); return usb_register(&cpia_driver);
} }
static void __exit usb_cpia_cleanup(void) static void __exit usb_cpia_cleanup(void)
{ {
/*
struct cam_data *cam;
while ((cam = cam_list) != NULL)
cpia_disconnect(NULL, cam);
*/
usb_deregister(&cpia_driver); usb_deregister(&cpia_driver);
} }
module_init (usb_cpia_init); module_init (usb_cpia_init);
module_exit (usb_cpia_cleanup); module_exit (usb_cpia_cleanup);
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