Lines Matching +full:sensor +full:- +full:gain

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
4 * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
8 * P/N 861037: Sensor HDCS1000 ASIC STV0600
9 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
10 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
11 * P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam
12 * P/N 861075-0040: Sensor HDCS1000 ASIC
13 * P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB
14 * P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web
18 * The spec file for the PB-0100 suggests the following for best quality
19 * images after the sensor has been reset :
23 * PB_PREADCTRL = R32 = 0x1400 (5120 dec) : Enables global gain changes
25 * PB_ADCMINGAIN = R52 = 0x10 (16 dec) : Sets the minimum gain for
26 auto-exposure
27 * PB_ADCGLOBALGAIN = R53 = 0x10 (16 dec) : Sets the global gain
28 * PB_EXPGAIN = R14 = 0x11 (17 dec) : Sets the auto-exposure value
30 auto-exposure routine
41 struct v4l2_ctrl *gain; member
78 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in pb0100_s_ctrl()
80 struct pb0100_ctrls *ctrls = sd->sensor_priv; in pb0100_s_ctrl()
81 int err = -EINVAL; in pb0100_s_ctrl()
83 switch (ctrl->id) { in pb0100_s_ctrl()
85 err = pb0100_set_autogain(gspca_dev, ctrl->val); in pb0100_s_ctrl()
88 if (ctrl->val) in pb0100_s_ctrl()
90 err = pb0100_set_gain(gspca_dev, ctrls->gain->val); in pb0100_s_ctrl()
93 err = pb0100_set_exposure(gspca_dev, ctrls->exposure->val); in pb0100_s_ctrl()
96 err = pb0100_set_autogain_target(gspca_dev, ctrl->val); in pb0100_s_ctrl()
108 struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; in pb0100_init_controls()
114 .name = "Automatic Gain Target", in pb0100_init_controls()
131 return -ENOMEM; in pb0100_init_controls()
134 ctrls->autogain = v4l2_ctrl_new_std(hdl, &pb0100_ctrl_ops, in pb0100_init_controls()
136 ctrls->exposure = v4l2_ctrl_new_std(hdl, &pb0100_ctrl_ops, in pb0100_init_controls()
138 ctrls->gain = v4l2_ctrl_new_std(hdl, &pb0100_ctrl_ops, in pb0100_init_controls()
140 ctrls->red = v4l2_ctrl_new_std(hdl, &pb0100_ctrl_ops, in pb0100_init_controls()
141 V4L2_CID_RED_BALANCE, -255, 255, 1, 0); in pb0100_init_controls()
142 ctrls->blue = v4l2_ctrl_new_std(hdl, &pb0100_ctrl_ops, in pb0100_init_controls()
143 V4L2_CID_BLUE_BALANCE, -255, 255, 1, 0); in pb0100_init_controls()
144 ctrls->natural = v4l2_ctrl_new_custom(hdl, &natural_light, NULL); in pb0100_init_controls()
145 ctrls->target = v4l2_ctrl_new_custom(hdl, &autogain_target, NULL); in pb0100_init_controls()
146 if (hdl->error) { in pb0100_init_controls()
148 return hdl->error; in pb0100_init_controls()
150 sd->sensor_priv = ctrls; in pb0100_init_controls()
151 v4l2_ctrl_auto_cluster(5, &ctrls->autogain, 0, false); in pb0100_init_controls()
157 u16 sensor; in pb0100_probe() local
160 err = stv06xx_read_sensor(sd, PB_IDENT, &sensor); in pb0100_probe()
163 return -ENODEV; in pb0100_probe()
164 if ((sensor >> 8) != 0x64) in pb0100_probe()
165 return -ENODEV; in pb0100_probe()
167 pr_info("Photobit pb0100 sensor detected\n"); in pb0100_probe()
169 sd->gspca_dev.cam.cam_mode = pb0100_mode; in pb0100_probe()
170 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(pb0100_mode); in pb0100_probe()
181 struct cam *cam = &sd->gspca_dev.cam; in pb0100_start()
182 u32 mode = cam->cam_mode[sd->gspca_dev.curr_mode].priv; in pb0100_start()
184 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); in pb0100_start()
185 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); in pb0100_start()
187 return -ENODEV; in pb0100_start()
189 if (alt->desc.bNumEndpoints < 1) in pb0100_start()
190 return -ENODEV; in pb0100_start()
192 packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); in pb0100_start()
195 max_packet_size = sd->sensor->max_packet_size[sd->gspca_dev.curr_mode]; in pb0100_start()
201 /* Setup sensor window */ in pb0100_start()
205 stv06xx_write_sensor(sd, PB_RWSIZE, 240 - 1); in pb0100_start()
206 stv06xx_write_sensor(sd, PB_CWSIZE, 320 - 1); in pb0100_start()
210 stv06xx_write_sensor(sd, PB_RWSIZE, 288 - 1); in pb0100_start()
211 stv06xx_write_sensor(sd, PB_CWSIZE, 352 - 1); in pb0100_start()
222 /* larger -> slower */ in pb0100_start()
259 /* Reset sensor */ in pb0100_init()
266 /* Gain stuff...*/ in pb0100_init()
270 /* Set up auto-exposure */ in pb0100_init()
274 /* gain max for autoexposure */ in pb0100_init()
276 /* gain min for autoexposure */ in pb0100_init()
279 allowed for auto-exposure routine */ in pb0100_init()
282 allowed for auto-exposure routine */ in pb0100_init()
285 /* R15 Expose0 (maximum that auto-exposure may use) */ in pb0100_init()
287 /* R17 Expose2 (minimum that auto-exposure may use) */ in pb0100_init()
304 /* Scan/timing for the sensor */ in pb0100_init()
325 struct pb0100_ctrls *ctrls = sd->sensor_priv; in pb0100_set_gain()
330 gspca_dbg(gspca_dev, D_CONF, "Set green gain to %d, status: %d\n", in pb0100_set_gain()
334 err = pb0100_set_red_balance(gspca_dev, ctrls->red->val); in pb0100_set_gain()
336 err = pb0100_set_blue_balance(gspca_dev, ctrls->blue->val); in pb0100_set_gain()
345 struct pb0100_ctrls *ctrls = sd->sensor_priv; in pb0100_set_red_balance()
347 val += ctrls->gain->val; in pb0100_set_red_balance()
354 gspca_dbg(gspca_dev, D_CONF, "Set red gain to %d, status: %d\n", in pb0100_set_red_balance()
364 struct pb0100_ctrls *ctrls = sd->sensor_priv; in pb0100_set_blue_balance()
366 val += ctrls->gain->val; in pb0100_set_blue_balance()
373 gspca_dbg(gspca_dev, D_CONF, "Set blue gain to %d, status: %d\n", in pb0100_set_blue_balance()
395 struct pb0100_ctrls *ctrls = sd->sensor_priv; in pb0100_set_autogain()
398 if (ctrls->natural->val) in pb0100_set_autogain()
407 val, ctrls->natural->val, err); in pb0100_set_autogain()
417 /* Number of pixels counted by the sensor when subsampling the pixels. in pb0100_set_autogain_target()
419 totalpixels = gspca_dev->pixfmt.width * gspca_dev->pixfmt.height; in pb0100_set_autogain_target()
423 darkpixels = totalpixels - brightpixels; in pb0100_set_autogain_target()