30 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32 #define MODULE_NAME "sq905c"
35 #include <linux/slab.h>
43 #define SQ905C_CMD_TIMEOUT 500
44 #define SQ905C_DATA_TIMEOUT 1000
47 #define SQ905C_MAX_TRANSFER 0x8000
49 #define FRAME_HEADER_LEN 0x50
52 #define SQ905C_CLEAR 0xa0
53 #define SQ905C_GET_ID 0x14f4
54 #define SQ905C_CAPTURE_LOW 0xa040
55 #define SQ905C_CAPTURE_MED 0x1440
56 #define SQ905C_CAPTURE_HI 0x2840
59 #define SQ905C_CAPTURE_INDEX 0x110f
78 .sizeimage = 320 * 240,
83 .sizeimage = 640 * 480,
94 usb_sndctrlpipe(gspca_dev->
dev, 0),
97 command, index,
NULL, 0,
100 pr_err(
"%s: usb_control_msg failed (%d)\n", __func__, ret);
107 static int sq905c_read(
struct gspca_dev *gspca_dev,
u16 command,
u16 index,
113 usb_rcvctrlpipe(gspca_dev->
dev, 0),
116 command, index, gspca_dev->
usb_buf, size,
119 pr_err(
"%s: usb_control_msg failed (%d)\n", __func__, ret);
137 struct gspca_dev *gspca_dev = &dev->
gspca_dev;
147 pr_err(
"Couldn't allocate USB buffer\n");
153 if (gspca_dev->frozen)
158 usb_rcvbulkpipe(gspca_dev->
dev, 0x81),
162 "Got %d bytes out of %d for header",
167 bytes_left = buffer[0x40]|(buffer[0x41]<<8)|(buffer[0x42]<<16)
169 PDEBUG(D_STREAM,
"bytes_left = 0x%x", bytes_left);
174 while (bytes_left > 0 && gspca_dev->
present) {
178 usb_rcvbulkpipe(gspca_dev->
dev, 0x81),
179 buffer, data_len, &act_len,
181 if (ret < 0 || act_len < data_len)
184 "Got %d bytes out of %d for frame",
185 data_len, bytes_left);
205 static int sd_config(
struct gspca_dev *gspca_dev,
209 struct sd *dev = (
struct sd *) gspca_dev;
213 "SQ9050 camera detected"
222 ret = sq905c_read(gspca_dev, 0xf5, 0, 20);
229 "SQ9050 ID string: %02x - %*ph",
234 if (gspca_dev->
usb_buf[15] == 0)
245 static void sd_stop0(
struct gspca_dev *gspca_dev)
247 struct sd *dev = (
struct sd *) gspca_dev;
258 static int sd_init(
struct gspca_dev *gspca_dev)
268 static int sd_start(
struct gspca_dev *gspca_dev)
270 struct sd *dev = (
struct sd *) gspca_dev;
275 switch (gspca_dev->
width) {
277 PDEBUG(D_STREAM,
"Start streaming at high resolution");
283 PDEBUG(D_STREAM,
"Start streaming at medium resolution");
301 {USB_DEVICE(0x2770, 0x905c)},
302 {USB_DEVICE(0x2770, 0x9050)},
303 {USB_DEVICE(0x2770, 0x9051)},
304 {USB_DEVICE(0x2770, 0x9052)},
305 {USB_DEVICE(0x2770, 0x913d)},
330 static struct usb_driver sd_driver = {
332 .id_table = device_table,
336 .suspend = gspca_suspend,
337 .resume = gspca_resume,
338 .reset_resume = gspca_resume,