Lines Matching +full:auto +full:- +full:load

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
6 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
16 * 0x1b Auto white balance related, bit 0 is AWB enable (inverted)
28 * generated JPG-s are only understood by v4l-utils >= 0.8.9
35 * 0x02 Clock divider 2-63, fps =~ 60 / val. Must be a multiple of 3 on
37 * 0x0f Master gain 1-245, low value = high gain
38 * 0x10 Another gain 0-15, limited influence (1-2x gain I guess)
39 * 0x21 Bitfield: 0-1 unused, 2-3 vflip/hflip, 4-5 unknown, 6-7 unused
59 MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li");
134 0, LOAD_PAGE4, /* load the page 4 */
140 /* page 4 - the value SKIP says skip the index - see reg_w_page() */
157 if (gspca_dev->usb_err < 0) in reg_w_buf()
159 memcpy(gspca_dev->usb_buf, buffer, len); in reg_w_buf()
160 ret = usb_control_msg(gspca_dev->dev, in reg_w_buf()
161 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w_buf()
165 index, gspca_dev->usb_buf, len, in reg_w_buf()
170 gspca_dev->usb_err = ret; in reg_w_buf()
181 if (gspca_dev->usb_err < 0) in reg_w()
183 gspca_dev->usb_buf[0] = value; in reg_w()
184 ret = usb_control_msg(gspca_dev->dev, in reg_w()
185 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w()
188 0, index, gspca_dev->usb_buf, 1, in reg_w()
193 gspca_dev->usb_err = ret; in reg_w()
200 while (--len >= 0) { in reg_w_seq()
206 /* load the beginning of a page */
213 if (gspca_dev->usb_err < 0) in reg_w_page()
218 gspca_dev->usb_buf[0] = page[index]; in reg_w_page()
219 ret = usb_control_msg(gspca_dev->dev, in reg_w_page()
220 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w_page()
223 0, index, gspca_dev->usb_buf, 1, in reg_w_page()
228 gspca_dev->usb_err = ret; in reg_w_page()
265 len -= 8; in reg_w_var()
276 struct cam *cam = &gspca_dev->cam; in sd_config()
278 cam->cam_mode = vga_mode; in sd_config()
279 cam->nmodes = ARRAY_SIZE(vga_mode); in sd_config()
280 cam->input_flags = V4L2_IN_ST_VFLIP; in sd_config()
289 /* load registers to sensor (Bit 0, auto clear) */ in setcontrast()
297 reg_w(gspca_dev, 0x0f, gspca_dev->gain->maximum - val + 1); in setgain()
299 /* load registers to sensor (Bit 0, auto clear) */ in setgain()
308 /* load registers to sensor (Bit 0, auto clear) */ in setexposure()
316 if (gspca_dev->pixfmt.width != 640 && val <= 3) in setexposure()
327 if (gspca_dev->pixfmt.width == 640 && val == 2) in setexposure()
332 /* load registers to sensor (Bit 0, auto clear) */ in setexposure()
345 /* load registers to sensor (Bit 0, auto clear) */ in sethvflip()
353 return gspca_dev->usb_err; in sd_init()
359 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
362 gspca_dev->usb_err = 0; in sd_s_ctrl()
364 if (ctrl->id == V4L2_CID_AUTOGAIN && ctrl->is_new && ctrl->val) { in sd_s_ctrl()
369 gspca_dev->exposure->val = PAC7311_EXPOSURE_DEFAULT; in sd_s_ctrl()
370 gspca_dev->gain->val = PAC7311_GAIN_DEFAULT; in sd_s_ctrl()
371 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; in sd_s_ctrl()
374 if (!gspca_dev->streaming) in sd_s_ctrl()
377 switch (ctrl->id) { in sd_s_ctrl()
379 setcontrast(gspca_dev, ctrl->val); in sd_s_ctrl()
382 if (gspca_dev->exposure->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
383 setexposure(gspca_dev, gspca_dev->exposure->val); in sd_s_ctrl()
384 if (gspca_dev->gain->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
385 setgain(gspca_dev, gspca_dev->gain->val); in sd_s_ctrl()
388 sethvflip(gspca_dev, sd->hflip->val, 1); in sd_s_ctrl()
391 return -EINVAL; in sd_s_ctrl()
393 return gspca_dev->usb_err; in sd_s_ctrl()
404 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
406 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
409 sd->contrast = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
411 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
413 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
416 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
419 sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
422 if (hdl->error) { in sd_init_controls()
424 return hdl->error; in sd_init_controls()
427 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); in sd_init_controls()
431 /* -- start the camera -- */
436 sd->sof_read = 0; in sd_start()
440 setcontrast(gspca_dev, v4l2_ctrl_g_ctrl(sd->contrast)); in sd_start()
441 setgain(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->gain)); in sd_start()
442 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); in sd_start()
443 sethvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), 1); in sd_start()
446 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { in sd_start()
464 sd->sof_read = 0; in sd_start()
465 sd->autogain_ignore_frames = 0; in sd_start()
466 atomic_set(&sd->avg_lum, -1); in sd_start()
472 return gspca_dev->usb_err; in sd_start()
492 int avg_lum = atomic_read(&sd->avg_lum); in do_autogain()
495 if (avg_lum == -1) in do_autogain()
501 if (sd->autogain_ignore_frames > 0) in do_autogain()
502 sd->autogain_ignore_frames--; in do_autogain()
505 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; in do_autogain()
564 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len); in sd_pkt_scan()
578 n = (sof - data) - (footer_length + sizeof pac_sof_marker); in sd_pkt_scan()
580 gspca_dev->image_len += n; in sd_pkt_scan()
585 image = gspca_dev->image; in sd_pkt_scan()
587 && image[gspca_dev->image_len - 2] == 0xff in sd_pkt_scan()
588 && image[gspca_dev->image_len - 1] == 0xd9) in sd_pkt_scan()
591 n = sof - data; in sd_pkt_scan()
592 len -= n; in sd_pkt_scan()
596 if (gspca_dev->last_packet_type == LAST_PACKET && in sd_pkt_scan()
598 atomic_set(&sd->avg_lum, data[-lum_offset] + in sd_pkt_scan()
599 data[-lum_offset + 1]); in sd_pkt_scan()
601 atomic_set(&sd->avg_lum, -1); in sd_pkt_scan()
605 gspca_dev->pixfmt.height, gspca_dev->pixfmt.width); in sd_pkt_scan()
615 int ret = -EINVAL; in sd_int_pkt_scan()
629 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); in sd_int_pkt_scan()
630 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
631 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); in sd_int_pkt_scan()
632 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
655 /* -- module initialisation -- */
667 /* -- device connect -- */