/* loop reading a frame */
again:
- while (gspca_dev->present && gspca_dev->streaming) {
+ while (!gspca_dev->frozen && gspca_dev->dev && gspca_dev->streaming) {
/* request a frame */
mutex_lock(&gspca_dev->usb_lock);
mutex_unlock(&gspca_dev->usb_lock);
if (ret < 0)
break;
- if (!gspca_dev->present || !gspca_dev->streaming)
+ if (gspca_dev->frozen || !gspca_dev->dev ||
+ !gspca_dev->streaming)
break;
/* the frame comes in parts */
* error. Just restart. */
goto again;
}
- if (!gspca_dev->present || !gspca_dev->streaming)
+ if (gspca_dev->frozen || !gspca_dev->dev ||
+ !gspca_dev->streaming)
goto out;
if (len < FPIX_MAX_TRANSFER ||
(data[len - 2] == 0xff &&
destroy_urbs(gspca_dev);
gspca_input_destroy_urb(gspca_dev);
gspca_set_alt0(gspca_dev);
- if (gspca_dev->sd_desc->stop0)
+ if (gspca_dev->sd_desc->stop0) {
+ mutex_lock(&gspca_dev->usb_lock);
gspca_dev->sd_desc->stop0(gspca_dev);
+ mutex_unlock(&gspca_dev->usb_lock);
+ }
return 0;
}
EXPORT_SYMBOL(gspca_suspend);
int gspca_resume(struct usb_interface *intf)
{
struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
- int streaming;
+ int streaming, ret = 0;
gspca_dev->frozen = 0;
gspca_dev->sd_desc->init(gspca_dev);
streaming = gspca_dev->streaming;
gspca_dev->streaming = 0;
v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler);
- if (streaming)
- return gspca_init_transfer(gspca_dev);
- return 0;
+ if (streaming) {
+ mutex_lock(&gspca_dev->queue_lock);
+ ret = gspca_init_transfer(gspca_dev);
+ mutex_unlock(&gspca_dev->queue_lock);
+ }
+ return ret;
}
EXPORT_SYMBOL(gspca_resume);
#endif
goto quit_stream;
}
- while (gspca_dev->present && gspca_dev->streaming) {
+ while (!gspca_dev->frozen && gspca_dev->dev && gspca_dev->streaming) {
/* Check if this is a new frame. If so, start the frame first */
if (!header_read) {
mutex_lock(&gspca_dev->usb_lock);
buffer, act_len);
header_read = 1;
}
- while (bytes_left > 0 && gspca_dev->present) {
+ while (bytes_left > 0 && gspca_dev->dev) {
data_len = bytes_left > JL2005C_MAX_TRANSFER ?
JL2005C_MAX_TRANSFER : bytes_left;
ret = usb_bulk_msg(gspca_dev->dev,
}
}
quit_stream:
- if (gspca_dev->present) {
+ if (gspca_dev->dev) {
mutex_lock(&gspca_dev->usb_lock);
jl2005c_stop(gspca_dev);
mutex_unlock(&gspca_dev->usb_lock);
frame_sz = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].sizeimage
+ FRAME_HEADER_LEN;
- while (gspca_dev->present && gspca_dev->streaming) {
+ while (!gspca_dev->frozen && gspca_dev->dev && gspca_dev->streaming) {
/* request some data and then read it until we have
* a complete frame. */
bytes_left = frame_sz;
we must finish reading an entire frame, otherwise the
next time we stream we start reading in the middle of a
frame. */
- while (bytes_left > 0 && gspca_dev->present) {
+ while (bytes_left > 0 && gspca_dev->dev) {
data_len = bytes_left > SQ905_MAX_TRANSFER ?
SQ905_MAX_TRANSFER : bytes_left;
ret = sq905_read_data(gspca_dev, buffer, data_len, 1);
gspca_frame_add(gspca_dev, LAST_PACKET,
NULL, 0);
}
- if (gspca_dev->present) {
+ if (gspca_dev->dev) {
/* acknowledge the frame */
mutex_lock(&gspca_dev->usb_lock);
ret = sq905_ack_frame(gspca_dev);
}
}
quit_stream:
- if (gspca_dev->present) {
+ if (gspca_dev->dev) {
mutex_lock(&gspca_dev->usb_lock);
sq905_command(gspca_dev, SQ905_CLEAR);
mutex_unlock(&gspca_dev->usb_lock);
goto quit_stream;
}
- while (gspca_dev->present && gspca_dev->streaming) {
+ while (!gspca_dev->frozen && gspca_dev->dev && gspca_dev->streaming) {
/* Request the header, which tells the size to download */
ret = usb_bulk_msg(gspca_dev->dev,
usb_rcvbulkpipe(gspca_dev->dev, 0x81),
packet_type = FIRST_PACKET;
gspca_frame_add(gspca_dev, packet_type,
buffer, FRAME_HEADER_LEN);
- while (bytes_left > 0 && gspca_dev->present) {
+ while (bytes_left > 0 && gspca_dev->dev) {
data_len = bytes_left > SQ905C_MAX_TRANSFER ?
SQ905C_MAX_TRANSFER : bytes_left;
ret = usb_bulk_msg(gspca_dev->dev,
}
}
quit_stream:
- if (gspca_dev->present) {
+ if (gspca_dev->dev) {
mutex_lock(&gspca_dev->usb_lock);
sq905c_command(gspca_dev, SQ905C_CLEAR, 0);
mutex_unlock(&gspca_dev->usb_lock);
goto exit;
}
- while (gspca_dev->present && gspca_dev->streaming) {
+ while (!gspca_dev->frozen && gspca_dev->dev && gspca_dev->streaming) {
ret = vicam_read_frame(gspca_dev, buffer, frame_sz);
if (ret < 0)
break;
dev->work_thread = NULL;
mutex_lock(&gspca_dev->usb_lock);
- if (gspca_dev->present)
+ if (gspca_dev->dev)
vicam_set_camera_power(gspca_dev, 0);
}
/* get the transfer status */
/* the bit 0 of the bridge register 11 indicates overflow */
mutex_lock(&gspca_dev->usb_lock);
- if (!gspca_dev->present || !gspca_dev->streaming)
+ if (gspca_dev->frozen || !gspca_dev->dev ||
+ !gspca_dev->streaming)
goto err;
reg11 = reg_r(gspca_dev, 0x0011);
if (gspca_dev->usb_err < 0
mutex_lock(&gspca_dev->usb_lock);
sd->work_thread = NULL;
}
- if (!gspca_dev->present)
+ if (!gspca_dev->dev)
return;
send_unknown(gspca_dev, sd->sensor);
}