2009-03-25 13:13:13 +03:00
|
|
|
/*
|
|
|
|
* SQ905C subdriver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Theodore Kilgore
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* This driver uses work done in
|
|
|
|
* libgphoto2/camlibs/digigr8, Copyright (C) Theodore Kilgore.
|
|
|
|
*
|
|
|
|
* This driver has also used as a base the sq905c driver
|
|
|
|
* and may contain code fragments from it.
|
|
|
|
*/
|
|
|
|
|
2011-08-22 02:56:57 +04:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-03-25 13:13:13 +03:00
|
|
|
#define MODULE_NAME "sq905c"
|
|
|
|
|
|
|
|
#include <linux/workqueue.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2009-03-25 13:13:13 +03:00
|
|
|
#include "gspca.h"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Theodore Kilgore <kilgota@auburn.edu>");
|
|
|
|
MODULE_DESCRIPTION("GSPCA/SQ905C USB Camera Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/* Default timeouts, in ms */
|
|
|
|
#define SQ905C_CMD_TIMEOUT 500
|
|
|
|
#define SQ905C_DATA_TIMEOUT 1000
|
|
|
|
|
|
|
|
/* Maximum transfer size to use. */
|
|
|
|
#define SQ905C_MAX_TRANSFER 0x8000
|
|
|
|
|
|
|
|
#define FRAME_HEADER_LEN 0x50
|
|
|
|
|
|
|
|
/* Commands. These go in the "value" slot. */
|
|
|
|
#define SQ905C_CLEAR 0xa0 /* clear everything */
|
2010-01-14 18:07:18 +03:00
|
|
|
#define SQ905C_GET_ID 0x14f4 /* Read version number */
|
2009-03-25 13:13:13 +03:00
|
|
|
#define SQ905C_CAPTURE_LOW 0xa040 /* Starts capture at 160x120 */
|
|
|
|
#define SQ905C_CAPTURE_MED 0x1440 /* Starts capture at 320x240 */
|
|
|
|
#define SQ905C_CAPTURE_HI 0x2840 /* Starts capture at 320x240 */
|
|
|
|
|
|
|
|
/* For capture, this must go in the "index" slot. */
|
|
|
|
#define SQ905C_CAPTURE_INDEX 0x110f
|
|
|
|
|
|
|
|
/* Structure to hold all of our device specific stuff */
|
|
|
|
struct sd {
|
|
|
|
struct gspca_dev gspca_dev; /* !! must be the first item */
|
|
|
|
const struct v4l2_pix_format *cap_mode;
|
|
|
|
/* Driver stuff */
|
|
|
|
struct work_struct work_struct;
|
|
|
|
struct workqueue_struct *work_thread;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Most of these cameras will do 640x480 and 320x240. 160x120 works
|
|
|
|
* in theory but gives very poor output. Therefore, not supported.
|
|
|
|
* The 0x2770:0x9050 cameras have max resolution of 320x240.
|
|
|
|
*/
|
|
|
|
static struct v4l2_pix_format sq905c_mode[] = {
|
|
|
|
{ 320, 240, V4L2_PIX_FMT_SQ905C, V4L2_FIELD_NONE,
|
|
|
|
.bytesperline = 320,
|
|
|
|
.sizeimage = 320 * 240,
|
|
|
|
.colorspace = V4L2_COLORSPACE_SRGB,
|
|
|
|
.priv = 0},
|
|
|
|
{ 640, 480, V4L2_PIX_FMT_SQ905C, V4L2_FIELD_NONE,
|
|
|
|
.bytesperline = 640,
|
|
|
|
.sizeimage = 640 * 480,
|
|
|
|
.colorspace = V4L2_COLORSPACE_SRGB,
|
|
|
|
.priv = 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Send a command to the camera. */
|
|
|
|
static int sq905c_command(struct gspca_dev *gspca_dev, u16 command, u16 index)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = usb_control_msg(gspca_dev->dev,
|
|
|
|
usb_sndctrlpipe(gspca_dev->dev, 0),
|
|
|
|
USB_REQ_SYNCH_FRAME, /* request */
|
|
|
|
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
|
|
|
command, index, NULL, 0,
|
|
|
|
SQ905C_CMD_TIMEOUT);
|
|
|
|
if (ret < 0) {
|
2011-08-22 02:56:57 +04:00
|
|
|
pr_err("%s: usb_control_msg failed (%d)\n", __func__, ret);
|
2009-03-25 13:13:13 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:07:18 +03:00
|
|
|
static int sq905c_read(struct gspca_dev *gspca_dev, u16 command, u16 index,
|
|
|
|
int size)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = usb_control_msg(gspca_dev->dev,
|
|
|
|
usb_rcvctrlpipe(gspca_dev->dev, 0),
|
|
|
|
USB_REQ_SYNCH_FRAME, /* request */
|
|
|
|
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
|
|
|
command, index, gspca_dev->usb_buf, size,
|
|
|
|
SQ905C_CMD_TIMEOUT);
|
|
|
|
if (ret < 0) {
|
2011-08-22 02:56:57 +04:00
|
|
|
pr_err("%s: usb_control_msg failed (%d)\n", __func__, ret);
|
2010-01-14 18:07:18 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-09 14:30:02 +04:00
|
|
|
/*
|
|
|
|
* This function is called as a workqueue function and runs whenever the camera
|
2009-03-25 13:13:13 +03:00
|
|
|
* is streaming data. Because it is a workqueue function it is allowed to sleep
|
|
|
|
* so we can use synchronous USB calls. To avoid possible collisions with other
|
2012-09-09 14:30:02 +04:00
|
|
|
* threads attempting to use gspca_dev->usb_buf we take the usb_lock when
|
|
|
|
* performing USB operations using it. In practice we don't really need this
|
|
|
|
* as the camera doesn't provide any controls.
|
2009-03-25 13:13:13 +03:00
|
|
|
*/
|
|
|
|
static void sq905c_dostream(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct sd *dev = container_of(work, struct sd, work_struct);
|
|
|
|
struct gspca_dev *gspca_dev = &dev->gspca_dev;
|
|
|
|
int bytes_left; /* bytes remaining in current frame. */
|
|
|
|
int data_len; /* size to use for the next read. */
|
|
|
|
int act_len;
|
|
|
|
int packet_type;
|
|
|
|
int ret;
|
|
|
|
u8 *buffer;
|
|
|
|
|
2018-05-05 11:22:08 +03:00
|
|
|
buffer = kmalloc(SQ905C_MAX_TRANSFER, GFP_KERNEL);
|
2009-03-25 13:13:13 +03:00
|
|
|
if (!buffer) {
|
2011-08-22 02:56:57 +04:00
|
|
|
pr_err("Couldn't allocate USB buffer\n");
|
2009-03-25 13:13:13 +03:00
|
|
|
goto quit_stream;
|
|
|
|
}
|
|
|
|
|
[media] gspca: Don't set gspca_dev->dev to NULL before stop0
In commit a3d6e8cc0e6ddc8b3cfdeb3c979f07ed1aa528b3 gspca_dev->dev is set
to NULL on disconnect, before calling stop0. The plan was to get rid of
gspca_dev->present and instead simply check for gspca_dev->dev everywhere
where we were checking for present. This should be race free since all users
of gspca_dev->dev hold the usb_lock, or so I thought.
But I was wrong, drivers which use a work-queue + synchronous bulk transfers
to get the video data don't hold the usb_lock while doing so, their stop0
callbacks stop the workqueue, so they won't be using gspca_dev->dev anymore
after the stop0 call, but they might be dereferincing it before, so we should
not set gspca_dev->dev to NULL on disconnect before calling stop0.
This also means that the workqueue functions in these drivers cannot
use gspca_dev->dev to check if they need to stop because of disconnection,
so we will need to keep gspca_dev->present around, and set that to 0 on
disconnect, before calling stop0. Unfortunately as part of the plan to remove
gspca_dev->present, these workqueues where already moved over to checking
for gspca_dev->dev instead of gspca_dev->present as part of commit
254902b01d2acc6aced99ec17caa4c6cd890cdea, so this patch also reverts those
parts of that commit.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-09 13:30:02 +04:00
|
|
|
while (gspca_dev->present && gspca_dev->streaming) {
|
2012-05-18 15:40:42 +04:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
if (gspca_dev->frozen)
|
|
|
|
break;
|
|
|
|
#endif
|
2009-03-25 13:13:13 +03:00
|
|
|
/* Request the header, which tells the size to download */
|
|
|
|
ret = usb_bulk_msg(gspca_dev->dev,
|
|
|
|
usb_rcvbulkpipe(gspca_dev->dev, 0x81),
|
|
|
|
buffer, FRAME_HEADER_LEN, &act_len,
|
|
|
|
SQ905C_DATA_TIMEOUT);
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_STREAM,
|
|
|
|
"Got %d bytes out of %d for header\n",
|
|
|
|
act_len, FRAME_HEADER_LEN);
|
2009-03-25 13:13:13 +03:00
|
|
|
if (ret < 0 || act_len < FRAME_HEADER_LEN)
|
|
|
|
goto quit_stream;
|
|
|
|
/* size is read from 4 bytes starting 0x40, little endian */
|
|
|
|
bytes_left = buffer[0x40]|(buffer[0x41]<<8)|(buffer[0x42]<<16)
|
|
|
|
|(buffer[0x43]<<24);
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_STREAM, "bytes_left = 0x%x\n",
|
|
|
|
bytes_left);
|
2009-03-25 13:13:13 +03:00
|
|
|
/* We keep the header. It has other information, too. */
|
|
|
|
packet_type = FIRST_PACKET;
|
2009-11-13 15:21:03 +03:00
|
|
|
gspca_frame_add(gspca_dev, packet_type,
|
|
|
|
buffer, FRAME_HEADER_LEN);
|
[media] gspca: Don't set gspca_dev->dev to NULL before stop0
In commit a3d6e8cc0e6ddc8b3cfdeb3c979f07ed1aa528b3 gspca_dev->dev is set
to NULL on disconnect, before calling stop0. The plan was to get rid of
gspca_dev->present and instead simply check for gspca_dev->dev everywhere
where we were checking for present. This should be race free since all users
of gspca_dev->dev hold the usb_lock, or so I thought.
But I was wrong, drivers which use a work-queue + synchronous bulk transfers
to get the video data don't hold the usb_lock while doing so, their stop0
callbacks stop the workqueue, so they won't be using gspca_dev->dev anymore
after the stop0 call, but they might be dereferincing it before, so we should
not set gspca_dev->dev to NULL on disconnect before calling stop0.
This also means that the workqueue functions in these drivers cannot
use gspca_dev->dev to check if they need to stop because of disconnection,
so we will need to keep gspca_dev->present around, and set that to 0 on
disconnect, before calling stop0. Unfortunately as part of the plan to remove
gspca_dev->present, these workqueues where already moved over to checking
for gspca_dev->dev instead of gspca_dev->present as part of commit
254902b01d2acc6aced99ec17caa4c6cd890cdea, so this patch also reverts those
parts of that commit.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-09 13:30:02 +04:00
|
|
|
while (bytes_left > 0 && gspca_dev->present) {
|
2009-03-25 13:13:13 +03:00
|
|
|
data_len = bytes_left > SQ905C_MAX_TRANSFER ?
|
|
|
|
SQ905C_MAX_TRANSFER : bytes_left;
|
|
|
|
ret = usb_bulk_msg(gspca_dev->dev,
|
|
|
|
usb_rcvbulkpipe(gspca_dev->dev, 0x81),
|
|
|
|
buffer, data_len, &act_len,
|
|
|
|
SQ905C_DATA_TIMEOUT);
|
|
|
|
if (ret < 0 || act_len < data_len)
|
|
|
|
goto quit_stream;
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_STREAM,
|
|
|
|
"Got %d bytes out of %d for frame\n",
|
|
|
|
data_len, bytes_left);
|
2009-03-25 13:13:13 +03:00
|
|
|
bytes_left -= data_len;
|
|
|
|
if (bytes_left == 0)
|
|
|
|
packet_type = LAST_PACKET;
|
|
|
|
else
|
|
|
|
packet_type = INTER_PACKET;
|
2009-11-13 15:21:03 +03:00
|
|
|
gspca_frame_add(gspca_dev, packet_type,
|
|
|
|
buffer, data_len);
|
2009-03-25 13:13:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
quit_stream:
|
[media] gspca: Don't set gspca_dev->dev to NULL before stop0
In commit a3d6e8cc0e6ddc8b3cfdeb3c979f07ed1aa528b3 gspca_dev->dev is set
to NULL on disconnect, before calling stop0. The plan was to get rid of
gspca_dev->present and instead simply check for gspca_dev->dev everywhere
where we were checking for present. This should be race free since all users
of gspca_dev->dev hold the usb_lock, or so I thought.
But I was wrong, drivers which use a work-queue + synchronous bulk transfers
to get the video data don't hold the usb_lock while doing so, their stop0
callbacks stop the workqueue, so they won't be using gspca_dev->dev anymore
after the stop0 call, but they might be dereferincing it before, so we should
not set gspca_dev->dev to NULL on disconnect before calling stop0.
This also means that the workqueue functions in these drivers cannot
use gspca_dev->dev to check if they need to stop because of disconnection,
so we will need to keep gspca_dev->present around, and set that to 0 on
disconnect, before calling stop0. Unfortunately as part of the plan to remove
gspca_dev->present, these workqueues where already moved over to checking
for gspca_dev->dev instead of gspca_dev->present as part of commit
254902b01d2acc6aced99ec17caa4c6cd890cdea, so this patch also reverts those
parts of that commit.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-09 13:30:02 +04:00
|
|
|
if (gspca_dev->present) {
|
2009-10-09 11:17:42 +04:00
|
|
|
mutex_lock(&gspca_dev->usb_lock);
|
2009-03-25 13:13:13 +03:00
|
|
|
sq905c_command(gspca_dev, SQ905C_CLEAR, 0);
|
2009-10-09 11:17:42 +04:00
|
|
|
mutex_unlock(&gspca_dev->usb_lock);
|
|
|
|
}
|
2009-03-25 13:13:13 +03:00
|
|
|
kfree(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function is called at probe time just before sd_init */
|
|
|
|
static int sd_config(struct gspca_dev *gspca_dev,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct cam *cam = &gspca_dev->cam;
|
|
|
|
struct sd *dev = (struct sd *) gspca_dev;
|
2010-01-17 09:58:51 +03:00
|
|
|
int ret;
|
2009-03-25 13:13:13 +03:00
|
|
|
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_PROBE,
|
|
|
|
"SQ9050 camera detected (vid/pid 0x%04X:0x%04X)\n",
|
|
|
|
id->idVendor, id->idProduct);
|
2010-01-14 18:07:18 +03:00
|
|
|
|
|
|
|
ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0);
|
|
|
|
if (ret < 0) {
|
2017-09-22 21:33:35 +03:00
|
|
|
gspca_err(gspca_dev, "Get version command failed\n");
|
2010-01-14 18:07:18 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sq905c_read(gspca_dev, 0xf5, 0, 20);
|
|
|
|
if (ret < 0) {
|
2017-09-22 21:33:35 +03:00
|
|
|
gspca_err(gspca_dev, "Reading version command failed\n");
|
2010-01-14 18:07:18 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* Note we leave out the usb id and the manufacturing date */
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_PROBE,
|
|
|
|
"SQ9050 ID string: %02x - %*ph\n",
|
|
|
|
gspca_dev->usb_buf[3], 6, gspca_dev->usb_buf + 14);
|
2010-01-14 18:07:18 +03:00
|
|
|
|
2009-03-25 13:13:13 +03:00
|
|
|
cam->cam_mode = sq905c_mode;
|
|
|
|
cam->nmodes = 2;
|
2010-01-14 18:07:18 +03:00
|
|
|
if (gspca_dev->usb_buf[15] == 0)
|
2009-03-25 13:13:13 +03:00
|
|
|
cam->nmodes = 1;
|
|
|
|
/* We don't use the buffer gspca allocates so make it small. */
|
|
|
|
cam->bulk_size = 32;
|
2009-04-21 20:45:56 +04:00
|
|
|
cam->bulk = 1;
|
2009-03-25 13:13:13 +03:00
|
|
|
INIT_WORK(&dev->work_struct, sq905c_dostream);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called on streamoff with alt==0 and on disconnect */
|
|
|
|
/* the usb_lock is held at entry - restore on exit */
|
|
|
|
static void sd_stop0(struct gspca_dev *gspca_dev)
|
|
|
|
{
|
|
|
|
struct sd *dev = (struct sd *) gspca_dev;
|
|
|
|
|
|
|
|
/* wait for the work queue to terminate */
|
|
|
|
mutex_unlock(&gspca_dev->usb_lock);
|
|
|
|
/* This waits for sq905c_dostream to finish */
|
|
|
|
destroy_workqueue(dev->work_thread);
|
|
|
|
dev->work_thread = NULL;
|
|
|
|
mutex_lock(&gspca_dev->usb_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this function is called at probe and resume time */
|
|
|
|
static int sd_init(struct gspca_dev *gspca_dev)
|
|
|
|
{
|
|
|
|
/* connect to the camera and reset it. */
|
2016-09-07 01:52:24 +03:00
|
|
|
return sq905c_command(gspca_dev, SQ905C_CLEAR, 0);
|
2009-03-25 13:13:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up for getting frames. */
|
|
|
|
static int sd_start(struct gspca_dev *gspca_dev)
|
|
|
|
{
|
|
|
|
struct sd *dev = (struct sd *) gspca_dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
dev->cap_mode = gspca_dev->cam.cam_mode;
|
|
|
|
/* "Open the shutter" and set size, to start capture */
|
2013-08-31 00:54:23 +04:00
|
|
|
switch (gspca_dev->pixfmt.width) {
|
2009-03-25 13:13:13 +03:00
|
|
|
case 640:
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_STREAM, "Start streaming at high resolution\n");
|
2009-03-25 13:13:13 +03:00
|
|
|
dev->cap_mode++;
|
|
|
|
ret = sq905c_command(gspca_dev, SQ905C_CAPTURE_HI,
|
|
|
|
SQ905C_CAPTURE_INDEX);
|
|
|
|
break;
|
|
|
|
default: /* 320 */
|
2017-09-22 22:20:33 +03:00
|
|
|
gspca_dbg(gspca_dev, D_STREAM, "Start streaming at medium resolution\n");
|
2009-03-25 13:13:13 +03:00
|
|
|
ret = sq905c_command(gspca_dev, SQ905C_CAPTURE_MED,
|
|
|
|
SQ905C_CAPTURE_INDEX);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret < 0) {
|
2017-09-22 21:33:35 +03:00
|
|
|
gspca_err(gspca_dev, "Start streaming command failed\n");
|
2009-03-25 13:13:13 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/* Start the workqueue function to do the streaming */
|
|
|
|
dev->work_thread = create_singlethread_workqueue(MODULE_NAME);
|
|
|
|
queue_work(dev->work_thread, &dev->work_struct);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Table of supported USB devices */
|
2011-01-13 11:20:29 +03:00
|
|
|
static const struct usb_device_id device_table[] = {
|
2009-03-25 13:13:13 +03:00
|
|
|
{USB_DEVICE(0x2770, 0x905c)},
|
|
|
|
{USB_DEVICE(0x2770, 0x9050)},
|
2010-12-24 23:06:04 +03:00
|
|
|
{USB_DEVICE(0x2770, 0x9051)},
|
2010-01-17 16:42:55 +03:00
|
|
|
{USB_DEVICE(0x2770, 0x9052)},
|
2009-03-25 13:13:13 +03:00
|
|
|
{USB_DEVICE(0x2770, 0x913d)},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, device_table);
|
|
|
|
|
|
|
|
/* sub-driver description */
|
|
|
|
static const struct sd_desc sd_desc = {
|
|
|
|
.name = MODULE_NAME,
|
|
|
|
.config = sd_config,
|
|
|
|
.init = sd_init,
|
|
|
|
.start = sd_start,
|
|
|
|
.stop0 = sd_stop0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -- device connect -- */
|
|
|
|
static int sd_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
return gspca_dev_probe(intf, id,
|
|
|
|
&sd_desc,
|
|
|
|
sizeof(struct sd),
|
|
|
|
THIS_MODULE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_driver sd_driver = {
|
|
|
|
.name = MODULE_NAME,
|
|
|
|
.id_table = device_table,
|
|
|
|
.probe = sd_probe,
|
|
|
|
.disconnect = gspca_disconnect,
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = gspca_suspend,
|
|
|
|
.resume = gspca_resume,
|
2012-06-30 13:44:47 +04:00
|
|
|
.reset_resume = gspca_resume,
|
2009-03-25 13:13:13 +03:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-11-18 21:46:12 +04:00
|
|
|
module_usb_driver(sd_driver);
|