Lines Matching +full:1 +full:x64 +full:- +full:bit
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
9 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
33 #define PAC207_EXPOSURE_MAX 90 /* 1 sec expo time / 1 fps */
69 .priv = 1},
81 {0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30},
89 struct usb_device *udev = gspca_dev->dev; in pac207_write_regs()
92 if (gspca_dev->usb_err < 0) in pac207_write_regs()
95 memcpy(gspca_dev->usb_buf, buffer, length); in pac207_write_regs()
100 gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT); in pac207_write_regs()
104 gspca_dev->usb_err = err; in pac207_write_regs()
110 struct usb_device *udev = gspca_dev->dev; in pac207_write_reg()
113 if (gspca_dev->usb_err < 0) in pac207_write_reg()
122 gspca_dev->usb_err = err; in pac207_write_reg()
128 struct usb_device *udev = gspca_dev->dev; in pac207_read_reg()
131 if (gspca_dev->usb_err < 0) in pac207_read_reg()
137 gspca_dev->usb_buf, 1, PAC207_CTRL_TIMEOUT); in pac207_read_reg()
141 gspca_dev->usb_err = res; in pac207_read_reg()
145 return gspca_dev->usb_buf[0]; in pac207_read_reg()
156 idreg[1] = pac207_read_reg(gspca_dev, 0x0001); in sd_config()
157 idreg[0] = ((idreg[0] & 0x0f) << 4) | ((idreg[1] & 0xf0) >> 4); in sd_config()
158 idreg[1] = idreg[1] & 0x0f; in sd_config()
160 idreg[0], idreg[1]); in sd_config()
164 return -ENODEV; in sd_config()
169 id->idVendor, id->idProduct); in sd_config()
171 cam = &gspca_dev->cam; in sd_config()
172 cam->cam_mode = sif_mode; in sd_config()
173 cam->nmodes = ARRAY_SIZE(sif_mode); in sd_config()
183 /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */ in sd_init()
191 return gspca_dev->usb_err; in sd_init()
197 pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */ in setcontrol()
204 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
207 gspca_dev->usb_err = 0; in sd_s_ctrl()
209 if (ctrl->id == V4L2_CID_AUTOGAIN && ctrl->is_new && ctrl->val) { in sd_s_ctrl()
214 gspca_dev->exposure->val = PAC207_EXPOSURE_DEFAULT; in sd_s_ctrl()
215 gspca_dev->gain->val = PAC207_GAIN_DEFAULT; in sd_s_ctrl()
216 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; in sd_s_ctrl()
219 if (!gspca_dev->streaming) in sd_s_ctrl()
222 switch (ctrl->id) { in sd_s_ctrl()
224 setcontrol(gspca_dev, PAC207_BRIGHTNESS_REG, ctrl->val); in sd_s_ctrl()
227 if (gspca_dev->exposure->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
229 gspca_dev->exposure->val); in sd_s_ctrl()
230 if (gspca_dev->gain->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
232 gspca_dev->gain->val); in sd_s_ctrl()
235 return -EINVAL; in sd_s_ctrl()
237 return gspca_dev->usb_err; in sd_s_ctrl()
248 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
250 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
253 sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
256 1, PAC207_BRIGHTNESS_DEFAULT); in sd_init_controls()
257 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
258 V4L2_CID_AUTOGAIN, 0, 1, 1, 1); in sd_init_controls()
259 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
262 1, PAC207_EXPOSURE_DEFAULT); in sd_init_controls()
263 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
266 1, PAC207_GAIN_DEFAULT); in sd_init_controls()
267 if (hdl->error) { in sd_init_controls()
269 return hdl->error; in sd_init_controls()
271 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); in sd_init_controls()
275 /* -- start the camera -- */
281 pac207_write_reg(gspca_dev, 0x0f, 0x10); /* Power control (Bit 6-0) */ in sd_start()
283 pac207_write_regs(gspca_dev, 0x000a, pac207_sensor_init[1], 8); in sd_start()
288 if (gspca_dev->pixfmt.width == 176) in sd_start()
293 pac207_write_reg(gspca_dev, 0x08, v4l2_ctrl_g_ctrl(sd->brightness)); in sd_start()
295 /* PGA global gain (Bit 4-0) */ in sd_start()
297 v4l2_ctrl_g_ctrl(gspca_dev->gain)); in sd_start()
299 v4l2_ctrl_g_ctrl(gspca_dev->exposure)); /* PXCK = 12MHz /n */ in sd_start()
301 /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */ in sd_start()
306 if (gspca_dev->pixfmt.width == 176) { /* 176x144 */ in sd_start()
314 pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */ in sd_start()
319 sd->sof_read = 0; in sd_start()
320 sd->autogain_ignore_frames = 0; in sd_start()
321 atomic_set(&sd->avg_lum, -1); in sd_start()
322 return gspca_dev->usb_err; in sd_start()
329 /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */ in sd_stopN()
343 int avg_lum = atomic_read(&sd->avg_lum); in pac207_do_auto_gain()
345 if (avg_lum == -1) in pac207_do_auto_gain()
348 if (sd->autogain_ignore_frames > 0) in pac207_do_auto_gain()
349 sd->autogain_ignore_frames--; in pac207_do_auto_gain()
352 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; in pac207_do_auto_gain()
362 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len); in sd_pkt_scan()
367 n = sof - data; in sd_pkt_scan()
369 n -= sizeof pac_sof_marker; in sd_pkt_scan()
374 sd->header_read = 0; in sd_pkt_scan()
376 len -= sof - data; in sd_pkt_scan()
379 if (sd->header_read < 11) { in sd_pkt_scan()
383 if (sd->header_read < 5) { in sd_pkt_scan()
384 needed = 5 - sd->header_read; in sd_pkt_scan()
386 atomic_set(&sd->avg_lum, data[needed - 1]); in sd_pkt_scan()
389 needed = 11 - sd->header_read; in sd_pkt_scan()
391 sd->header_read += len; in sd_pkt_scan()
395 len -= needed; in sd_pkt_scan()
396 sd->header_read = 11; in sd_pkt_scan()
407 int ret = -EINVAL; in sd_int_pkt_scan()
409 if (len == 2 && data[0] == 0x5a && data[1] == 0x5a) { in sd_int_pkt_scan()
410 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); in sd_int_pkt_scan()
411 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
412 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); in sd_int_pkt_scan()
413 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
421 /* sub-driver description */
436 /* -- module initialisation -- */
455 /* -- device connect -- */