aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sq905c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/sq905c.c')
-rw-r--r--drivers/media/video/gspca/sq905c.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index 916892505432..d70b156872d6 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -115,11 +115,9 @@ static void sq905c_dostream(struct work_struct *work)
115{ 115{
116 struct sd *dev = container_of(work, struct sd, work_struct); 116 struct sd *dev = container_of(work, struct sd, work_struct);
117 struct gspca_dev *gspca_dev = &dev->gspca_dev; 117 struct gspca_dev *gspca_dev = &dev->gspca_dev;
118 struct gspca_frame *frame;
119 int bytes_left; /* bytes remaining in current frame. */ 118 int bytes_left; /* bytes remaining in current frame. */
120 int data_len; /* size to use for the next read. */ 119 int data_len; /* size to use for the next read. */
121 int act_len; 120 int act_len;
122 int discarding = 0; /* true if we failed to get space for frame. */
123 int packet_type; 121 int packet_type;
124 int ret; 122 int ret;
125 u8 *buffer; 123 u8 *buffer;
@@ -131,8 +129,6 @@ static void sq905c_dostream(struct work_struct *work)
131 } 129 }
132 130
133 while (gspca_dev->present && gspca_dev->streaming) { 131 while (gspca_dev->present && gspca_dev->streaming) {
134 if (!gspca_dev->present)
135 goto quit_stream;
136 /* Request the header, which tells the size to download */ 132 /* Request the header, which tells the size to download */
137 ret = usb_bulk_msg(gspca_dev->dev, 133 ret = usb_bulk_msg(gspca_dev->dev,
138 usb_rcvbulkpipe(gspca_dev->dev, 0x81), 134 usb_rcvbulkpipe(gspca_dev->dev, 0x81),
@@ -149,17 +145,11 @@ static void sq905c_dostream(struct work_struct *work)
149 PDEBUG(D_STREAM, "bytes_left = 0x%x", bytes_left); 145 PDEBUG(D_STREAM, "bytes_left = 0x%x", bytes_left);
150 /* We keep the header. It has other information, too. */ 146 /* We keep the header. It has other information, too. */
151 packet_type = FIRST_PACKET; 147 packet_type = FIRST_PACKET;
152 frame = gspca_get_i_frame(gspca_dev); 148 gspca_frame_add(gspca_dev, packet_type,
153 if (frame && !discarding) { 149 buffer, FRAME_HEADER_LEN);
154 gspca_frame_add(gspca_dev, packet_type, 150 while (bytes_left > 0 && gspca_dev->present) {
155 frame, buffer, FRAME_HEADER_LEN);
156 } else
157 discarding = 1;
158 while (bytes_left > 0) {
159 data_len = bytes_left > SQ905C_MAX_TRANSFER ? 151 data_len = bytes_left > SQ905C_MAX_TRANSFER ?
160 SQ905C_MAX_TRANSFER : bytes_left; 152 SQ905C_MAX_TRANSFER : bytes_left;
161 if (!gspca_dev->present)
162 goto quit_stream;
163 ret = usb_bulk_msg(gspca_dev->dev, 153 ret = usb_bulk_msg(gspca_dev->dev,
164 usb_rcvbulkpipe(gspca_dev->dev, 0x81), 154 usb_rcvbulkpipe(gspca_dev->dev, 0x81),
165 buffer, data_len, &act_len, 155 buffer, data_len, &act_len,
@@ -174,19 +164,16 @@ static void sq905c_dostream(struct work_struct *work)
174 packet_type = LAST_PACKET; 164 packet_type = LAST_PACKET;
175 else 165 else
176 packet_type = INTER_PACKET; 166 packet_type = INTER_PACKET;
177 frame = gspca_get_i_frame(gspca_dev); 167 gspca_frame_add(gspca_dev, packet_type,
178 if (frame && !discarding) 168 buffer, data_len);
179 gspca_frame_add(gspca_dev, packet_type,
180 frame, buffer, data_len);
181 else
182 discarding = 1;
183 } 169 }
184 } 170 }
185quit_stream: 171quit_stream:
186 mutex_lock(&gspca_dev->usb_lock); 172 if (gspca_dev->present) {
187 if (gspca_dev->present) 173 mutex_lock(&gspca_dev->usb_lock);
188 sq905c_command(gspca_dev, SQ905C_CLEAR, 0); 174 sq905c_command(gspca_dev, SQ905C_CLEAR, 0);
189 mutex_unlock(&gspca_dev->usb_lock); 175 mutex_unlock(&gspca_dev->usb_lock);
176 }
190 kfree(buffer); 177 kfree(buffer);
191} 178}
192 179