Lines Matching +full:camera +full:- +full:command +full:- +full:set
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * STV0680 USB Camera Driver
9 * STV0680 USB Camera Driver, by Kevin Sisson (kjsisson@bellsouth.net)
23 MODULE_DESCRIPTION("STV0680 USB Camera Driver");
35 static int stv_sndctrl(struct gspca_dev *gspca_dev, int set, u8 req, u16 val, in stv_sndctrl() argument
42 switch (set) { in stv_sndctrl()
45 pipe = usb_rcvctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
49 pipe = usb_sndctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
53 pipe = usb_rcvctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
57 pipe = usb_sndctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
61 ret = usb_control_msg(gspca_dev->dev, pipe, in stv_sndctrl()
63 val, 0, gspca_dev->usb_buf, size, 500); in stv_sndctrl()
67 set, req, ret); in stv_sndctrl()
75 gspca_err(gspca_dev, "last error: %i, command = 0x%x\n", in stv0680_handle_error()
76 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); in stv0680_handle_error()
83 memset(gspca_dev->usb_buf, 0, 8); in stv0680_get_video_mode()
84 gspca_dev->usb_buf[0] = 0x0f; in stv0680_get_video_mode()
88 return stv0680_handle_error(gspca_dev, -EIO); in stv0680_get_video_mode()
91 return gspca_dev->usb_buf[0]; /* 01 = VGA, 03 = QVGA, 00 = CIF */ in stv0680_get_video_mode()
98 if (sd->current_mode == mode) in stv0680_set_video_mode()
101 memset(gspca_dev->usb_buf, 0, 8); in stv0680_set_video_mode()
102 gspca_dev->usb_buf[0] = mode; in stv0680_set_video_mode()
106 return stv0680_handle_error(gspca_dev, -EIO); in stv0680_set_video_mode()
111 gspca_err(gspca_dev, "Error setting camera video mode!\n"); in stv0680_set_video_mode()
112 return -EIO; in stv0680_set_video_mode()
115 sd->current_mode = mode; in stv0680_set_video_mode()
126 struct cam *cam = &gspca_dev->cam; in sd_config()
128 /* Give the camera some time to settle, otherwise initialization will in sd_config()
132 /* ping camera to be sure STV0680 is present */ in sd_config()
134 gspca_dev->usb_buf[0] != 0x56 || gspca_dev->usb_buf[1] != 0x78) { in sd_config()
135 gspca_err(gspca_dev, "STV(e): camera ping failed!!\n"); in sd_config()
136 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
139 /* get camera descriptor */ in sd_config()
141 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
144 gspca_dev->usb_buf[7] != 0xa0 || gspca_dev->usb_buf[8] != 0x23) { in sd_config()
146 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
149 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
151 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
153 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
155 if (!(gspca_dev->usb_buf[7] & 0x09)) { in sd_config()
156 gspca_err(gspca_dev, "Camera supports neither CIF nor QVGA mode\n"); in sd_config()
157 return -ENODEV; in sd_config()
159 if (gspca_dev->usb_buf[7] & 0x01) in sd_config()
160 gspca_dbg(gspca_dev, D_PROBE, "Camera supports CIF mode\n"); in sd_config()
161 if (gspca_dev->usb_buf[7] & 0x02) in sd_config()
162 gspca_dbg(gspca_dev, D_PROBE, "Camera supports VGA mode\n"); in sd_config()
163 if (gspca_dev->usb_buf[7] & 0x04) in sd_config()
164 gspca_dbg(gspca_dev, D_PROBE, "Camera supports QCIF mode\n"); in sd_config()
165 if (gspca_dev->usb_buf[7] & 0x08) in sd_config()
166 gspca_dbg(gspca_dev, D_PROBE, "Camera supports QVGA mode\n"); in sd_config()
168 if (gspca_dev->usb_buf[7] & 0x01) in sd_config()
169 sd->video_mode = 0x00; /* CIF */ in sd_config()
171 sd->video_mode = 0x03; /* QVGA */ in sd_config()
175 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); in sd_config()
177 gspca_dev->usb_buf[2], gspca_dev->usb_buf[3]); in sd_config()
179 (gspca_dev->usb_buf[4]*16) + (gspca_dev->usb_buf[5]>>4)); in sd_config()
185 sd->current_mode = sd->orig_mode = ret; in sd_config()
187 ret = stv0680_set_video_mode(gspca_dev, sd->video_mode); in sd_config()
193 return stv0680_handle_error(gspca_dev, -EIO); in sd_config()
195 cam->bulk = 1; in sd_config()
196 cam->bulk_nurbs = 1; /* The cam cannot handle more */ in sd_config()
197 cam->bulk_size = (gspca_dev->usb_buf[0] << 24) | in sd_config()
198 (gspca_dev->usb_buf[1] << 16) | in sd_config()
199 (gspca_dev->usb_buf[2] << 8) | in sd_config()
200 (gspca_dev->usb_buf[3]); in sd_config()
201 sd->mode.width = (gspca_dev->usb_buf[4] << 8) | in sd_config()
202 (gspca_dev->usb_buf[5]); /* 322, 356, 644 */ in sd_config()
203 sd->mode.height = (gspca_dev->usb_buf[6] << 8) | in sd_config()
204 (gspca_dev->usb_buf[7]); /* 242, 292, 484 */ in sd_config()
205 sd->mode.pixelformat = V4L2_PIX_FMT_STV0680; in sd_config()
206 sd->mode.field = V4L2_FIELD_NONE; in sd_config()
207 sd->mode.bytesperline = sd->mode.width; in sd_config()
208 sd->mode.sizeimage = cam->bulk_size; in sd_config()
209 sd->mode.colorspace = V4L2_COLORSPACE_SRGB; in sd_config()
211 /* origGain = gspca_dev->usb_buf[12]; */ in sd_config()
213 cam->cam_mode = &sd->mode; in sd_config()
214 cam->nmodes = 1; in sd_config()
217 ret = stv0680_set_video_mode(gspca_dev, sd->orig_mode); in sd_config()
222 gspca_dev->usb_buf[8] != 0x53 || gspca_dev->usb_buf[9] != 0x05) { in sd_config()
224 return stv0680_handle_error(gspca_dev, -EIO); in sd_config()
236 /* -- start the camera -- */
242 ret = stv0680_set_video_mode(gspca_dev, sd->video_mode); in sd_start()
247 return stv0680_handle_error(gspca_dev, -EIO); in sd_start()
253 if (stv_sndctrl(gspca_dev, 1, 0x09, sd->video_mode << 8, 0x0) != 0x0) in sd_start()
254 return stv0680_handle_error(gspca_dev, -EIO); in sd_start()
261 /* This is a high priority command; it stops all lower order cmds */ in sd_stopN()
263 stv0680_handle_error(gspca_dev, -EIO); in sd_stopN()
270 if (!sd->gspca_dev.present) in sd_stop0()
273 stv0680_set_video_mode(gspca_dev, sd->orig_mode); in sd_stop0()
282 /* Every now and then the camera sends a 16 byte packet, no idea in sd_pkt_scan()
286 if (len != sd->mode.sizeimage) { in sd_pkt_scan()
287 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
300 /* sub-driver description */
311 /* -- module initialisation -- */
319 /* -- device connect -- */