30 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32 #define MODULE_NAME "stv0680"
54 unsigned int pipe = 0;
59 pipe = usb_rcvctrlpipe(gspca_dev->
dev, 0);
63 pipe = usb_sndctrlpipe(gspca_dev->
dev, 0);
67 pipe = usb_rcvctrlpipe(gspca_dev->
dev, 0);
71 pipe = usb_sndctrlpipe(gspca_dev->
dev, 0);
77 val, 0, gspca_dev->
usb_buf, size, 500);
79 if ((ret < 0) && (req != 0x0a))
80 pr_err(
"usb_control_msg error %i, request = 0x%x, error = %i\n",
86 static int stv0680_handle_error(
struct gspca_dev *gspca_dev,
int ret)
88 stv_sndctrl(gspca_dev, 0, 0x80, 0, 0x02);
94 static int stv0680_get_video_mode(
struct gspca_dev *gspca_dev)
100 if (stv_sndctrl(gspca_dev, 0, 0x87, 0, 0x08) != 0x08) {
102 return stv0680_handle_error(gspca_dev, -
EIO);
108 static int stv0680_set_video_mode(
struct gspca_dev *gspca_dev,
u8 mode)
110 struct sd *
sd = (
struct sd *) gspca_dev;
118 if (stv_sndctrl(gspca_dev, 3, 0x07, 0x0100, 0x08) != 0x08) {
120 return stv0680_handle_error(gspca_dev, -
EIO);
124 if (stv0680_get_video_mode(gspca_dev) != mode) {
135 static int sd_config(
struct gspca_dev *gspca_dev,
139 struct sd *sd = (
struct sd *) gspca_dev;
147 if (stv_sndctrl(gspca_dev, 0, 0x88, 0x5678, 0x02) != 0x02 ||
150 return stv0680_handle_error(gspca_dev, -
ENODEV);
154 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x09) != 0x09)
155 return stv0680_handle_error(gspca_dev, -
ENODEV);
157 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x22) != 0x22 ||
160 return stv0680_handle_error(gspca_dev, -
ENODEV);
162 if (stv_sndctrl(gspca_dev, 0, 0x8a, 0, 0x02) != 0x02)
163 return stv0680_handle_error(gspca_dev, -
ENODEV);
164 if (stv_sndctrl(gspca_dev, 0, 0x8b, 0, 0x24) != 0x24)
165 return stv0680_handle_error(gspca_dev, -
ENODEV);
166 if (stv_sndctrl(gspca_dev, 0, 0x85, 0, 0x10) != 0x10)
167 return stv0680_handle_error(gspca_dev, -
ENODEV);
169 if (!(gspca_dev->
usb_buf[7] & 0x09)) {
170 PDEBUG(
D_ERR,
"Camera supports neither CIF nor QVGA mode");
173 if (gspca_dev->
usb_buf[7] & 0x01)
174 PDEBUG(D_PROBE,
"Camera supports CIF mode");
175 if (gspca_dev->
usb_buf[7] & 0x02)
176 PDEBUG(D_PROBE,
"Camera supports VGA mode");
177 if (gspca_dev->
usb_buf[7] & 0x04)
178 PDEBUG(D_PROBE,
"Camera supports QCIF mode");
179 if (gspca_dev->
usb_buf[7] & 0x08)
180 PDEBUG(D_PROBE,
"Camera supports QVGA mode");
182 if (gspca_dev->
usb_buf[7] & 0x01)
188 PDEBUG(D_PROBE,
"Firmware rev is %i.%i",
190 PDEBUG(D_PROBE,
"ASIC rev is %i.%i",
192 PDEBUG(D_PROBE,
"Sensor ID is %i",
196 ret = stv0680_get_video_mode(gspca_dev);
201 ret = stv0680_set_video_mode(gspca_dev, sd->
video_mode);
206 if (stv_sndctrl(gspca_dev, 0, 0x8f, 0, 0x10) != 0x10)
207 return stv0680_handle_error(gspca_dev, -
EIO);
212 (gspca_dev->
usb_buf[1] << 16) |
221 sd->
mode.bytesperline = sd->
mode.width;
231 ret = stv0680_set_video_mode(gspca_dev, sd->
orig_mode);
235 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0100, 0x12) != 0x12 ||
237 pr_err(
"Could not get descriptor 0100\n");
238 return stv0680_handle_error(gspca_dev, -
EIO);
245 static int sd_init(
struct gspca_dev *gspca_dev)
251 static int sd_start(
struct gspca_dev *gspca_dev)
254 struct sd *sd = (
struct sd *) gspca_dev;
256 ret = stv0680_set_video_mode(gspca_dev, sd->
video_mode);
260 if (stv_sndctrl(gspca_dev, 0, 0x85, 0, 0x10) != 0x10)
261 return stv0680_handle_error(gspca_dev, -
EIO);
267 if (stv_sndctrl(gspca_dev, 1, 0x09, sd->
video_mode << 8, 0x0) != 0x0)
268 return stv0680_handle_error(gspca_dev, -
EIO);
273 static void sd_stopN(
struct gspca_dev *gspca_dev)
276 if (stv_sndctrl(gspca_dev, 1, 0x04, 0x0000, 0x0) != 0x0)
277 stv0680_handle_error(gspca_dev, -
EIO);
280 static void sd_stop0(
struct gspca_dev *gspca_dev)
282 struct sd *sd = (
struct sd *) gspca_dev;
287 stv0680_set_video_mode(gspca_dev, sd->
orig_mode);
290 static void sd_pkt_scan(
struct gspca_dev *gspca_dev,
294 struct sd *sd = (
struct sd *) gspca_dev;
300 if (len != sd->
mode.sizeimage) {
322 .pkt_scan = sd_pkt_scan,
327 {USB_DEVICE(0x0553, 0x0202)},
328 {USB_DEVICE(0x041e, 0x4007)},
341 static struct usb_driver sd_driver = {
343 .id_table = device_table,
347 .suspend = gspca_suspend,
348 .resume = gspca_resume,
349 .reset_resume = gspca_resume,