Lines Matching +full:cam +full:- +full:if
1 // SPDX-License-Identifier: GPL-2.0-or-later
31 MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, Theodore Kilgore <kilgota@auburn.edu>");
52 /* Any non-zero value in the bottom 2 bits of the 2nd byte of
53 * the ID appears to indicate the camera can do 640*480. If the
106 gspca_dev->usb_buf[0] = '\0'; in sq905_command()
107 ret = usb_control_msg(gspca_dev->dev, in sq905_command()
108 usb_sndctrlpipe(gspca_dev->dev, 0), in sq905_command()
111 SQ905_COMMAND, index, gspca_dev->usb_buf, 1, in sq905_command()
113 if (ret < 0) { in sq905_command()
118 ret = usb_control_msg(gspca_dev->dev, in sq905_command()
119 usb_rcvctrlpipe(gspca_dev->dev, 0), in sq905_command()
122 SQ905_PING, 0, gspca_dev->usb_buf, 1, in sq905_command()
124 if (ret < 0) { in sq905_command()
133 * Acknowledge the end of a frame - see warning on sq905_command.
139 gspca_dev->usb_buf[0] = '\0'; in sq905_ack_frame()
140 ret = usb_control_msg(gspca_dev->dev, in sq905_ack_frame()
141 usb_sndctrlpipe(gspca_dev->dev, 0), in sq905_ack_frame()
144 SQ905_READ_DONE, 0, gspca_dev->usb_buf, 1, in sq905_ack_frame()
146 if (ret < 0) { in sq905_ack_frame()
155 * request and read a block of data - see warning on sq905_command.
163 gspca_dev->usb_buf[0] = '\0'; in sq905_read_data()
164 if (need_lock) in sq905_read_data()
165 mutex_lock(&gspca_dev->usb_lock); in sq905_read_data()
166 ret = usb_control_msg(gspca_dev->dev, in sq905_read_data()
167 usb_sndctrlpipe(gspca_dev->dev, 0), in sq905_read_data()
170 SQ905_BULK_READ, size, gspca_dev->usb_buf, in sq905_read_data()
172 if (need_lock) in sq905_read_data()
173 mutex_unlock(&gspca_dev->usb_lock); in sq905_read_data()
174 if (ret < 0) { in sq905_read_data()
178 ret = usb_bulk_msg(gspca_dev->dev, in sq905_read_data()
179 usb_rcvbulkpipe(gspca_dev->dev, 0x81), in sq905_read_data()
183 if (ret < 0 || act_len != size) { in sq905_read_data()
185 return -EIO; in sq905_read_data()
194 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
201 struct gspca_dev *gspca_dev = &dev->gspca_dev; in sq905_dostream()
204 int header_read; /* true if we have already read the frame header. */ in sq905_dostream()
212 if (!buffer) { in sq905_dostream()
217 frame_sz = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].sizeimage in sq905_dostream()
220 while (gspca_dev->present && gspca_dev->streaming) { in sq905_dostream()
222 if (gspca_dev->frozen) in sq905_dostream()
230 /* Note we do not check for gspca_dev->streaming here, as in sq905_dostream()
234 while (bytes_left > 0 && gspca_dev->present) { in sq905_dostream()
238 if (ret < 0) in sq905_dostream()
243 bytes_left -= data_len; in sq905_dostream()
245 if (!header_read) { in sq905_dostream()
250 data_len -= FRAME_HEADER_LEN; in sq905_dostream()
252 } else if (bytes_left == 0) { in sq905_dostream()
259 /* If entire frame fits in one packet we still in sq905_dostream()
261 if (packet_type == FIRST_PACKET && in sq905_dostream()
266 if (gspca_dev->present) { in sq905_dostream()
268 mutex_lock(&gspca_dev->usb_lock); in sq905_dostream()
270 mutex_unlock(&gspca_dev->usb_lock); in sq905_dostream()
271 if (ret < 0) in sq905_dostream()
276 if (gspca_dev->present) { in sq905_dostream()
277 mutex_lock(&gspca_dev->usb_lock); in sq905_dostream()
279 mutex_unlock(&gspca_dev->usb_lock); in sq905_dostream()
288 struct cam *cam = &gspca_dev->cam; in sd_config() local
292 cam->bulk = 1; in sd_config()
293 cam->bulk_size = 64; in sd_config()
295 INIT_WORK(&dev->work_struct, sq905_dostream); in sd_config()
301 /* the usb_lock is held at entry - restore on exit */
307 mutex_unlock(&gspca_dev->usb_lock); in sd_stop0()
309 destroy_workqueue(dev->work_thread); in sd_stop0()
310 dev->work_thread = NULL; in sd_stop0()
311 mutex_lock(&gspca_dev->usb_lock); in sd_stop0()
324 if (ret < 0) in sd_init()
327 if (ret < 0) in sd_init()
329 ret = sq905_read_data(gspca_dev, gspca_dev->usb_buf, 4, 0); in sd_init()
330 if (ret < 0) in sd_init()
333 * Camera model number is the right way round if we assume this in sd_init()
335 ident = be32_to_cpup((__be32 *)gspca_dev->usb_buf); in sd_init()
337 if (ret < 0) in sd_init()
340 gspca_dev->cam.cam_mode = sq905_mode; in sd_init()
341 gspca_dev->cam.nmodes = ARRAY_SIZE(sq905_mode); in sd_init()
342 if (!(ident & SQ905_HIRES_MASK)) in sd_init()
343 gspca_dev->cam.nmodes--; in sd_init()
345 if (ident & SQ905_ORIENTATION_MASK) in sd_init()
346 gspca_dev->cam.input_flags = V4L2_IN_ST_VFLIP; in sd_init()
348 gspca_dev->cam.input_flags = V4L2_IN_ST_VFLIP | in sd_init()
360 switch (gspca_dev->curr_mode) { in sd_start()
364 ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_HIGH); in sd_start()
368 ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED); in sd_start()
372 ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_LOW); in sd_start()
375 if (ret < 0) { in sd_start()
380 dev->work_thread = create_singlethread_workqueue(MODULE_NAME); in sd_start()
381 if (!dev->work_thread) in sd_start()
382 return -ENOMEM; in sd_start()
384 queue_work(dev->work_thread, &dev->work_struct); in sd_start()
397 /* sub-driver description */
406 /* -- device connect -- */