Lines Matching +full:camera +full:- +full:command +full:- +full:set
1 // SPDX-License-Identifier: GPL-2.0-or-later
31 MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, Theodore Kilgore <[email protected]>");
32 MODULE_DESCRIPTION("GSPCA/SQ905 USB Camera Driver");
48 #define SQ905_COMMAND 0x06 /* precedes the command codes below */
49 #define SQ905_PING 0x07 /* when reading an "idling" command */
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
54 * LSB of that byte is set the image is just upside down, otherwise
59 /* Some command codes. These go in the "index" slot. */
68 /* note that the capture command also controls the output dimensions */
100 * Send a command to the camera.
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()
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()
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()
155 * request and read a block of data - see warning on sq905_command.
163 gspca_dev->usb_buf[0] = '\0'; 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()
173 mutex_unlock(&gspca_dev->usb_lock); 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()
185 return -EIO; in sq905_read_data()
191 * This function is called as a workqueue function and runs whenever the camera
194 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
196 * as the camera doesn't provide any controls.
201 struct gspca_dev *gspca_dev = &dev->gspca_dev; 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()
243 bytes_left -= data_len; in sq905_dostream()
250 data_len -= FRAME_HEADER_LEN; 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()
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()
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()
320 /* connect to the camera and read in sd_init()
329 ret = sq905_read_data(gspca_dev, gspca_dev->usb_buf, 4, 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()
339 gspca_dbg(gspca_dev, D_CONF, "SQ905 camera ID %08x detected\n", ident); 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()
343 gspca_dev->cam.nmodes--; 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()
353 /* Set up for getting frames. */
359 /* "Open the shutter" and set size, to start capture */ in sd_start()
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()
376 gspca_err(gspca_dev, "Start streaming command failed\n"); 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 -- */