X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fmedia%2Fusbvideo.c;fp=drivers%2Fmedia%2Fvideo%2Fusbvideo%2Fusbvideo.c;h=63a72e550a1bd049d0346d10d1ea440554d5354f;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=13b37c8c0d5624969776e5607ab1340b13c48244;hpb=f7ed79d23a47594e7834d66a8f14449796d4f3e6;p=linux-2.6.git diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/usb/media/usbvideo.c similarity index 98% rename from drivers/media/video/usbvideo/usbvideo.c rename to drivers/usb/media/usbvideo.c index 13b37c8c0..63a72e550 100644 --- a/drivers/media/video/usbvideo/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -574,7 +574,7 @@ void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode) } else { /* Just the blue screen */ } - + *f++ = cb; *f++ = cg; *f++ = cr; @@ -690,13 +690,14 @@ int usbvideo_register( } base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); - cams = (struct usbvideo *) kzalloc(base_size, GFP_KERNEL); + cams = (struct usbvideo *) kmalloc(base_size, GFP_KERNEL); if (cams == NULL) { err("Failed to allocate %d. bytes for usbvideo struct", base_size); return -ENOMEM; } dbg("%s: Allocated $%p (%d. bytes) for %d. cameras", __FUNCTION__, cams, base_size, num_cams); + memset(cams, 0, base_size); /* Copy callbacks, apply defaults for those that are not set */ memmove(&cams->cb, cbTbl, sizeof(cams->cb)); @@ -714,7 +715,7 @@ int usbvideo_register( cams->md_module = md; if (cams->md_module == NULL) warn("%s: module == NULL!", __FUNCTION__); - mutex_init(&cams->lock); /* to 1 == available */ + init_MUTEX(&cams->lock); /* to 1 == available */ for (i = 0; i < num_cams; i++) { struct uvd *up = &cams->cam[i]; @@ -862,7 +863,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) if (uvd->debug > 0) info("%s(%p.)", __FUNCTION__, intf); - mutex_lock(&uvd->lock); + down(&uvd->lock); uvd->remove_pending = 1; /* Now all ISO data will be ignored */ /* At this time we ask to cancel outstanding URBs */ @@ -882,7 +883,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) info("%s: In use, disconnect pending.", __FUNCTION__); else usbvideo_CameraRelease(uvd); - mutex_unlock(&uvd->lock); + up(&uvd->lock); info("USB camera disconnected."); usbvideo_ClientDecModCount(uvd); @@ -929,19 +930,19 @@ static int usbvideo_find_struct(struct usbvideo *cams) err("No usbvideo handle?"); return -1; } - mutex_lock(&cams->lock); + down(&cams->lock); for (u = 0; u < cams->num_cameras; u++) { struct uvd *uvd = &cams->cam[u]; if (!uvd->uvd_used) /* This one is free */ { uvd->uvd_used = 1; /* In use now */ - mutex_init(&uvd->lock); /* to 1 == available */ + init_MUTEX(&uvd->lock); /* to 1 == available */ uvd->dev = NULL; rv = u; break; } } - mutex_unlock(&cams->lock); + up(&cams->lock); return rv; } @@ -983,7 +984,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) /* Not relying upon caller we increase module counter ourselves */ usbvideo_ClientIncModCount(uvd); - mutex_lock(&uvd->lock); + down(&uvd->lock); for (i=0; i < USBVIDEO_NUMSBUF; i++) { uvd->sbuf[i].urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); if (uvd->sbuf[i].urb == NULL) { @@ -1006,7 +1007,7 @@ struct uvd *usbvideo_AllocateDevice(struct usbvideo *cams) * return control to the client's probe function right now. */ allocate_done: - mutex_unlock(&uvd->lock); + up (&uvd->lock); usbvideo_ClientDecModCount(uvd); return uvd; } @@ -1120,7 +1121,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) info("%s($%p)", __FUNCTION__, dev); usbvideo_ClientIncModCount(uvd); - mutex_lock(&uvd->lock); + down(&uvd->lock); if (uvd->user) { err("%s: Someone tried to open an already opened device!", __FUNCTION__); @@ -1201,7 +1202,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) } } } - mutex_unlock(&uvd->lock); + up(&uvd->lock); if (errCode != 0) usbvideo_ClientDecModCount(uvd); if (uvd->debug > 0) @@ -1230,7 +1231,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) if (uvd->debug > 1) info("%s($%p)", __FUNCTION__, dev); - mutex_lock(&uvd->lock); + down(&uvd->lock); GET_CALLBACK(uvd, stopDataPump)(uvd); usbvideo_rvfree(uvd->fbuf, uvd->fbuf_size); uvd->fbuf = NULL; @@ -1243,7 +1244,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) #if USBVIDEO_REPORT_STATS usbvideo_ReportStatistics(uvd); -#endif +#endif uvd->user--; if (uvd->remove_pending) { @@ -1251,7 +1252,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) info("usbvideo_v4l_close: Final disconnect."); usbvideo_CameraRelease(uvd); } - mutex_unlock(&uvd->lock); + up(&uvd->lock); usbvideo_ClientDecModCount(uvd); if (uvd->debug > 1) @@ -1290,7 +1291,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file, return 0; } case VIDIOCSCHAN: - { + { struct video_channel *v = arg; if (v->channel != 0) return -EINVAL; @@ -1347,7 +1348,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file, vw->chromakey = 0; if (VALID_CALLBACK(uvd, getFPS)) vw->flags = GET_CALLBACK(uvd, getFPS)(uvd); - else + else vw->flags = 10; /* FIXME: do better! */ return 0; } @@ -1359,7 +1360,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file, memset(vm, 0, sizeof(*vm)); vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES; vm->frames = USBVIDEO_NUMFRAMES; - for(i = 0; i < USBVIDEO_NUMFRAMES; i++) + for(i = 0; i < USBVIDEO_NUMFRAMES; i++) vm->offsets[i] = i * uvd->max_frame_size; return 0; @@ -1425,7 +1426,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file, if (*frameNum < 0 || *frameNum >= USBVIDEO_NUMFRAMES) return -EINVAL; - + if (uvd->debug >= 1) info("VIDIOCSYNC: syncing to frame %d.", *frameNum); if (uvd->flags & FLAGS_NO_DECODING) @@ -1454,8 +1455,8 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file, struct video_buffer *vb = arg; memset(vb, 0, sizeof(*vb)); - return 0; - } + return 0; + } case VIDIOCKEY: return 0; @@ -1511,7 +1512,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, if (uvd->debug >= 1) info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock); - mutex_lock(&uvd->lock); + down(&uvd->lock); /* See if a frame is completed, then use it. */ for(i = 0; i < USBVIDEO_NUMFRAMES; i++) { @@ -1643,7 +1644,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, } } read_done: - mutex_unlock(&uvd->lock); + up(&uvd->lock); return count; } @@ -1704,7 +1705,7 @@ static void usbvideo_IsocIrq(struct urb *urb, struct pt_regs *regs) info("Not streaming, but interrupt!"); return; } - + uvd->stats.urb_count++; if (urb->actual_length <= 0) goto urb_done_with; @@ -1763,7 +1764,7 @@ static int usbvideo_StartDataPump(struct uvd *uvd) } if (VALID_CALLBACK(uvd, videoStart)) GET_CALLBACK(uvd, videoStart)(uvd); - else + else err("%s: videoStart not set", __FUNCTION__); /* We double buffer the Iso lists */ @@ -1830,7 +1831,7 @@ static void usbvideo_StopDataPump(struct uvd *uvd) /* Invoke minidriver's magic to stop the camera */ if (VALID_CALLBACK(uvd, videoStop)) GET_CALLBACK(uvd, videoStop)(uvd); - else + else err("%s: videoStop not set", __FUNCTION__); /* Set packet size to 0 */ @@ -1963,14 +1964,14 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum); switch (frame->frameState) { - case FrameState_Unused: + case FrameState_Unused: if (uvd->debug >= 2) info("%s: FrameState_Unused", __FUNCTION__); return -EINVAL; - case FrameState_Ready: - case FrameState_Grabbing: - case FrameState_Error: - { + case FrameState_Ready: + case FrameState_Grabbing: + case FrameState_Error: + { int ntries, signalPending; redo: if (!CAMERA_IS_OPERATIONAL(uvd)) { @@ -1978,7 +1979,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) info("%s: Camera is not operational (1)", __FUNCTION__); return -EIO; } - ntries = 0; + ntries = 0; do { RingQueue_InterruptibleSleepOn(&uvd->dp); signalPending = signal_pending(current); @@ -2010,7 +2011,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) usbvideo_CollectRawData(uvd, frame); else if (VALID_CALLBACK(uvd, processData)) GET_CALLBACK(uvd, processData)(uvd, frame); - else + else err("%s: processData not set", __FUNCTION__); } } while (frame->frameState == FrameState_Grabbing); @@ -2027,8 +2028,8 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) goto redo; } /* Note that we fall through to meet our destiny below */ - } - case FrameState_Done: + } + case FrameState_Done: /* * Do all necessary postprocessing of data prepared in * "interrupt" code and the collecting code above. The @@ -2157,7 +2158,7 @@ EXPORT_SYMBOL(usbvideo_DeinterlaceFrame); * History: * 09-Feb-2001 Created. */ -static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, +static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, struct usbvideo_frame *frame) { int i, j, v4l_linesize;