Lines Matching refs:gspca_dev
38 struct gspca_dev gspca_dev; /* !! must be the first item */ member
45 static int stv_sndctrl(struct gspca_dev *gspca_dev, int set, u8 req, u16 val, in stv_sndctrl() argument
55 pipe = usb_rcvctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
59 pipe = usb_sndctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
63 pipe = usb_rcvctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
67 pipe = usb_sndctrlpipe(gspca_dev->dev, 0); in stv_sndctrl()
71 ret = usb_control_msg(gspca_dev->dev, pipe, in stv_sndctrl()
73 val, 0, gspca_dev->usb_buf, size, 500); in stv_sndctrl()
82 static int stv0680_handle_error(struct gspca_dev *gspca_dev, int ret) in stv0680_handle_error() argument
84 stv_sndctrl(gspca_dev, 0, 0x80, 0, 0x02); /* Get Last Error */ in stv0680_handle_error()
85 gspca_err(gspca_dev, "last error: %i, command = 0x%x\n", in stv0680_handle_error()
86 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); in stv0680_handle_error()
90 static int stv0680_get_video_mode(struct gspca_dev *gspca_dev) in stv0680_get_video_mode() argument
93 memset(gspca_dev->usb_buf, 0, 8); in stv0680_get_video_mode()
94 gspca_dev->usb_buf[0] = 0x0f; in stv0680_get_video_mode()
96 if (stv_sndctrl(gspca_dev, 0, 0x87, 0, 0x08) != 0x08) { in stv0680_get_video_mode()
97 gspca_err(gspca_dev, "Get_Camera_Mode failed\n"); in stv0680_get_video_mode()
98 return stv0680_handle_error(gspca_dev, -EIO); in stv0680_get_video_mode()
101 return gspca_dev->usb_buf[0]; /* 01 = VGA, 03 = QVGA, 00 = CIF */ in stv0680_get_video_mode()
104 static int stv0680_set_video_mode(struct gspca_dev *gspca_dev, u8 mode) in stv0680_set_video_mode() argument
106 struct sd *sd = (struct sd *) gspca_dev; in stv0680_set_video_mode()
111 memset(gspca_dev->usb_buf, 0, 8); in stv0680_set_video_mode()
112 gspca_dev->usb_buf[0] = mode; in stv0680_set_video_mode()
114 if (stv_sndctrl(gspca_dev, 3, 0x07, 0x0100, 0x08) != 0x08) { in stv0680_set_video_mode()
115 gspca_err(gspca_dev, "Set_Camera_Mode failed\n"); in stv0680_set_video_mode()
116 return stv0680_handle_error(gspca_dev, -EIO); in stv0680_set_video_mode()
120 if (stv0680_get_video_mode(gspca_dev) != mode) { in stv0680_set_video_mode()
121 gspca_err(gspca_dev, "Error setting camera video mode!\n"); in stv0680_set_video_mode()
131 static int sd_config(struct gspca_dev *gspca_dev, in sd_config() argument
135 struct sd *sd = (struct sd *) gspca_dev; in sd_config()
136 struct cam *cam = &gspca_dev->cam; in sd_config()
143 if (stv_sndctrl(gspca_dev, 0, 0x88, 0x5678, 0x02) != 0x02 || in sd_config()
144 gspca_dev->usb_buf[0] != 0x56 || gspca_dev->usb_buf[1] != 0x78) { in sd_config()
145 gspca_err(gspca_dev, "STV(e): camera ping failed!!\n"); in sd_config()
146 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
150 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x09) != 0x09) in sd_config()
151 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
153 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x22) != 0x22 || in sd_config()
154 gspca_dev->usb_buf[7] != 0xa0 || gspca_dev->usb_buf[8] != 0x23) { in sd_config()
155 gspca_err(gspca_dev, "Could not get descriptor 0200\n"); in sd_config()
156 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
158 if (stv_sndctrl(gspca_dev, 0, 0x8a, 0, 0x02) != 0x02) in sd_config()
159 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
160 if (stv_sndctrl(gspca_dev, 0, 0x8b, 0, 0x24) != 0x24) in sd_config()
161 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
162 if (stv_sndctrl(gspca_dev, 0, 0x85, 0, 0x10) != 0x10) in sd_config()
163 return stv0680_handle_error(gspca_dev, -ENODEV); in sd_config()
165 if (!(gspca_dev->usb_buf[7] & 0x09)) { in sd_config()
166 gspca_err(gspca_dev, "Camera supports neither CIF nor QVGA mode\n"); in sd_config()
169 if (gspca_dev->usb_buf[7] & 0x01) in sd_config()
170 gspca_dbg(gspca_dev, D_PROBE, "Camera supports CIF mode\n"); in sd_config()
171 if (gspca_dev->usb_buf[7] & 0x02) in sd_config()
172 gspca_dbg(gspca_dev, D_PROBE, "Camera supports VGA mode\n"); in sd_config()
173 if (gspca_dev->usb_buf[7] & 0x04) in sd_config()
174 gspca_dbg(gspca_dev, D_PROBE, "Camera supports QCIF mode\n"); in sd_config()
175 if (gspca_dev->usb_buf[7] & 0x08) in sd_config()
176 gspca_dbg(gspca_dev, D_PROBE, "Camera supports QVGA mode\n"); in sd_config()
178 if (gspca_dev->usb_buf[7] & 0x01) in sd_config()
184 gspca_dbg(gspca_dev, D_PROBE, "Firmware rev is %i.%i\n", in sd_config()
185 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); in sd_config()
186 gspca_dbg(gspca_dev, D_PROBE, "ASIC rev is %i.%i", in sd_config()
187 gspca_dev->usb_buf[2], gspca_dev->usb_buf[3]); in sd_config()
188 gspca_dbg(gspca_dev, D_PROBE, "Sensor ID is %i", in sd_config()
189 (gspca_dev->usb_buf[4]*16) + (gspca_dev->usb_buf[5]>>4)); in sd_config()
192 ret = stv0680_get_video_mode(gspca_dev); in sd_config()
197 ret = stv0680_set_video_mode(gspca_dev, sd->video_mode); in sd_config()
202 if (stv_sndctrl(gspca_dev, 0, 0x8f, 0, 0x10) != 0x10) in sd_config()
203 return stv0680_handle_error(gspca_dev, -EIO); in sd_config()
207 cam->bulk_size = (gspca_dev->usb_buf[0] << 24) | in sd_config()
208 (gspca_dev->usb_buf[1] << 16) | in sd_config()
209 (gspca_dev->usb_buf[2] << 8) | in sd_config()
210 (gspca_dev->usb_buf[3]); in sd_config()
211 sd->mode.width = (gspca_dev->usb_buf[4] << 8) | in sd_config()
212 (gspca_dev->usb_buf[5]); /* 322, 356, 644 */ in sd_config()
213 sd->mode.height = (gspca_dev->usb_buf[6] << 8) | in sd_config()
214 (gspca_dev->usb_buf[7]); /* 242, 292, 484 */ in sd_config()
227 ret = stv0680_set_video_mode(gspca_dev, sd->orig_mode); in sd_config()
231 if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0100, 0x12) != 0x12 || in sd_config()
232 gspca_dev->usb_buf[8] != 0x53 || gspca_dev->usb_buf[9] != 0x05) { in sd_config()
234 return stv0680_handle_error(gspca_dev, -EIO); in sd_config()
241 static int sd_init(struct gspca_dev *gspca_dev) in sd_init() argument
247 static int sd_start(struct gspca_dev *gspca_dev) in sd_start() argument
250 struct sd *sd = (struct sd *) gspca_dev; in sd_start()
252 ret = stv0680_set_video_mode(gspca_dev, sd->video_mode); in sd_start()
256 if (stv_sndctrl(gspca_dev, 0, 0x85, 0, 0x10) != 0x10) in sd_start()
257 return stv0680_handle_error(gspca_dev, -EIO); in sd_start()
263 if (stv_sndctrl(gspca_dev, 1, 0x09, sd->video_mode << 8, 0x0) != 0x0) in sd_start()
264 return stv0680_handle_error(gspca_dev, -EIO); in sd_start()
269 static void sd_stopN(struct gspca_dev *gspca_dev) in sd_stopN() argument
272 if (stv_sndctrl(gspca_dev, 1, 0x04, 0x0000, 0x0) != 0x0) in sd_stopN()
273 stv0680_handle_error(gspca_dev, -EIO); in sd_stopN()
276 static void sd_stop0(struct gspca_dev *gspca_dev) in sd_stop0() argument
278 struct sd *sd = (struct sd *) gspca_dev; in sd_stop0()
280 if (!sd->gspca_dev.present) in sd_stop0()
283 stv0680_set_video_mode(gspca_dev, sd->orig_mode); in sd_stop0()
286 static void sd_pkt_scan(struct gspca_dev *gspca_dev, in sd_pkt_scan() argument
290 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan()
297 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
304 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); in sd_pkt_scan()
307 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len); in sd_pkt_scan()