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

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2010 Jean-François Moine <http://moinejf.free.fr>
6 * Copyright (C) 2006 -2008 Gerard Klaver <gerard at gkall dot hobby dot nl>
16 MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>\n"
26 struct { /* exposure/gain control cluster */
28 struct v4l2_ctrl *gain; member
33 u8 sensor; member
199 {0x30, 0x0040}, /* reserved - def 0x0005 */
200 {0x31, 0x0000}, /* reserved - def 0x002a */
201 {0x34, 0x0100}, /* reserved - def 0x0100 */
202 {0x3d, 0x068f}, /* reserved - def 0x068f */
209 {0x35, 0x0020}, /* global gain */
210 {0x2b, 0x0020}, /* green1 gain */
211 {0x2c, 0x002a}, /* blue gain */
212 {0x2d, 0x0028}, /* red gain */
213 {0x2e, 0x0020}, /* green2 gain */
224 {0x62, 0x041d}, /* reserved - def 0x0418 */
237 {0x01, 0x0004}, /* select sensor core registers */
247 {0x35, 0x0020}, /* global gain */
248 {0x2b, 0x0020}, /* green1 gain */
249 {0x2c, 0x0020}, /* blue gain */
250 {0x2d, 0x0020}, /* red gain */
251 {0x2e, 0x0020}, /* green2 gain */
279 /* start parameters indexed by [sensor][mode] */
417 if (gspca_dev->usb_err < 0) in reg_r()
419 ret = usb_control_msg(gspca_dev->dev, in reg_r()
420 usb_rcvctrlpipe(gspca_dev->dev, 0), in reg_r()
423 value, 0, gspca_dev->usb_buf, len, in reg_r()
427 gspca_dev->usb_err = ret; in reg_r()
432 memset(gspca_dev->usb_buf, 0, USB_BUF_SZ); in reg_r()
440 if (gspca_dev->usb_err < 0) in reg_w()
443 ret = usb_control_msg(gspca_dev->dev, in reg_w()
444 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w()
452 gspca_dev->usb_err = ret; in reg_w()
461 if (gspca_dev->usb_err < 0) in reg_wb()
464 value, index, *data, data[len - 1]); in reg_wb()
465 memcpy(gspca_dev->usb_buf, data, len); in reg_wb()
466 ret = usb_control_msg(gspca_dev->dev, in reg_wb()
467 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_wb()
470 value, index, gspca_dev->usb_buf, len, in reg_wb()
475 gspca_dev->usb_err = ret; in reg_wb()
483 struct gspca_dev *gspca_dev = &sd->gspca_dev; in i2c_write()
484 const struct sensor_s *sensor; in i2c_write() local
489 if (gspca_dev->usb_err < 0) in i2c_write()
492 sensor = &sensor_tb[sd->sensor]; in i2c_write()
494 val = (sensor->i2c_addr << 8) | SQ930_CTRL_I2C_IO; in i2c_write()
495 idx = (cmd->val & 0xff00) | cmd->reg; in i2c_write()
497 buf = gspca_dev->usb_buf; in i2c_write()
498 *buf++ = sensor->i2c_dum; in i2c_write()
499 *buf++ = cmd->val; in i2c_write()
501 while (--ncmds > 0) { in i2c_write()
503 *buf++ = cmd->reg; in i2c_write()
504 *buf++ = cmd->val >> 8; in i2c_write()
505 *buf++ = sensor->i2c_dum; in i2c_write()
506 *buf++ = cmd->val; in i2c_write()
510 val, idx, gspca_dev->usb_buf[0], buf[-1]); in i2c_write()
511 ret = usb_control_msg(gspca_dev->dev, in i2c_write()
512 usb_sndctrlpipe(gspca_dev->dev, 0), in i2c_write()
516 gspca_dev->usb_buf, buf - gspca_dev->usb_buf, in i2c_write()
520 gspca_dev->usb_err = ret; in i2c_write()
533 if (gspca_dev->usb_err < 0) in ucbus_write()
536 if ((batchsize - 1) * 3 > USB_BUF_SZ) { in ucbus_write()
538 gspca_dev->usb_err = -ENOMEM; in ucbus_write()
546 ncmds -= len; in ucbus_write()
548 val = (cmd->bw_addr << 8) | SQ930_CTRL_UCBUS_IO; in ucbus_write()
549 idx = (cmd->bw_data << 8) | (cmd->bw_addr >> 8); in ucbus_write()
551 buf = gspca_dev->usb_buf; in ucbus_write()
552 while (--len > 0) { in ucbus_write()
554 *buf++ = cmd->bw_addr; in ucbus_write()
555 *buf++ = cmd->bw_addr >> 8; in ucbus_write()
556 *buf++ = cmd->bw_data; in ucbus_write()
558 if (buf != gspca_dev->usb_buf) in ucbus_write()
561 gspca_dev->usb_buf[0], buf[-1]); in ucbus_write()
565 ret = usb_control_msg(gspca_dev->dev, in ucbus_write()
566 usb_sndctrlpipe(gspca_dev->dev, 0), in ucbus_write()
570 gspca_dev->usb_buf, buf - gspca_dev->usb_buf, in ucbus_write()
574 gspca_dev->usb_err = ret; in ucbus_write()
586 struct gspca_dev *gspca_dev = &sd->gspca_dev; in gpio_set()
589 sd->gpio[0] &= ~mask; in gpio_set()
590 sd->gpio[0] |= val; in gpio_set()
592 ~sd->gpio[0] << 8); in gpio_set()
597 sd->gpio[1] &= ~mask; in gpio_set()
598 sd->gpio[1] |= val; in gpio_set()
600 ~sd->gpio[1] << 8); in gpio_set()
620 ucbus_write(&sd->gspca_dev, &clkfreq_cmd, 1, 1); in bridge_init()
629 const struct sensor_s *sensor; in cmos_probe() local
639 sensor = &sensor_tb[probe_order[i]]; in cmos_probe()
640 ucbus_write(&sd->gspca_dev, sensor->cmd, sensor->cmd_len, 8); in cmos_probe()
641 gpio_init(sd, sensor->gpio); in cmos_probe()
643 reg_r(gspca_dev, (sensor->i2c_addr << 8) | 0x001c, 1); in cmos_probe()
645 if (gspca_dev->usb_buf[0] != 0) in cmos_probe()
649 pr_err("Unknown sensor\n"); in cmos_probe()
650 gspca_dev->usb_err = -EINVAL; in cmos_probe()
653 sd->sensor = probe_order[i]; in cmos_probe()
654 switch (sd->sensor) { in cmos_probe()
657 pr_err("Sensor %s not yet treated\n", in cmos_probe()
658 sensor_tb[sd->sensor].name); in cmos_probe()
659 gspca_dev->usb_err = -EINVAL; in cmos_probe()
686 if (gspca_dev->usb_buf[0] == 0 in mt9v111_init()
687 || gspca_dev->usb_err != 0) in mt9v111_init()
689 if (--nwait < 0) { in mt9v111_init()
691 gspca_dev->usb_err = -ETIME; in mt9v111_init()
701 switch (sd->sensor) { in global_init()
704 ucbus_write(&sd->gspca_dev, in global_init()
707 gpio_init(sd, sensor_tb[sd->sensor].gpio); in global_init()
710 if (sd->type != Creative_live_motion) in global_init()
716 ucbus_write(&sd->gspca_dev, in global_init()
719 gpio_init(sd, sensor_tb[sd->sensor].gpio); in global_init()
723 ucbus_write(&sd->gspca_dev, in global_init()
727 gpio_init(sd, sensor_tb[sd->sensor].gpio); in global_init()
733 mt9v111_init(&sd->gspca_dev); in global_init()
735 gpio_init(sd, sensor_tb[sd->sensor].gpio); in global_init()
747 ucbus_write(&sd->gspca_dev, cmds, ARRAY_SIZE(cmds), 2); in lz24bp_ppl()
750 static void setexposure(struct gspca_dev *gspca_dev, s32 expo, s32 gain) in setexposure() argument
754 const struct sensor_s *sensor; in setexposure() local
762 switch (sd->sensor) { in setexposure()
765 min_frclk = sd->sensor == SENSOR_ICX098BQ ? 0x210 : 0x26f; in setexposure()
770 intstartclk = min_frclk - integclks; in setexposure()
777 buf[i++] = gain; in setexposure()
783 sensor = &sensor_tb[sd->sensor]; in setexposure()
784 buf[i++] = sensor->i2c_addr; /* i2c_slave_addr */ in setexposure()
788 buf[i++] = sensor->i2c_dum; in setexposure()
790 buf[i++] = 0x35; /* reg = global gain */ in setexposure()
792 buf[i++] = sensor->i2c_dum; in setexposure()
793 buf[i++] = 0x80 + gain / 2; /* val L */ in setexposure()
809 struct cam *cam = &gspca_dev->cam; in sd_config()
811 sd->sensor = id->driver_info >> 8; in sd_config()
812 sd->type = id->driver_info; in sd_config()
814 cam->cam_mode = vga_mode; in sd_config()
815 cam->nmodes = ARRAY_SIZE(vga_mode); in sd_config()
817 cam->bulk = 1; in sd_config()
827 sd->gpio[0] = sd->gpio[1] = 0xff; /* force gpio rewrite */ in sd_init()
830 if (sd->sensor != SENSOR_LZ24BP) in sd_init()
835 if (gspca_dev->usb_err < 0) in sd_init()
836 return gspca_dev->usb_err; in sd_init()
841 * 03 00 12 93 0b fe c8 00 Trust WB-3500T in sd_init()
842 * 02 00 06 93 0b fe c8 00 Joy-IT 318S in sd_init()
843 * 03 00 12 93 0b f6 cf 00 icam tracer - sensor icx098bq in sd_init()
853 * 6: c8 / c9 / ca / cf = mode webcam?, sensor? webcam? in sd_init()
856 gspca_dbg(gspca_dev, D_PROBE, "info: %*ph\n", 8, gspca_dev->usb_buf); in sd_init()
860 if (sd->sensor == SENSOR_MI0360) { in sd_init()
862 /* no sensor probe for icam tracer */ in sd_init()
863 if (gspca_dev->usb_buf[5] == 0xf6) /* if ccd */ in sd_init()
864 sd->sensor = SENSOR_ICX098BQ; in sd_init()
868 if (gspca_dev->usb_err >= 0) { in sd_init()
869 gspca_dbg(gspca_dev, D_PROBE, "Sensor %s\n", in sd_init()
870 sensor_tb[sd->sensor].name); in sd_init()
873 return gspca_dev->usb_err; in sd_init()
883 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; in send_start()
884 cap = &capconfig[sd->sensor][mode]; in send_start()
886 0x0a00 | cap->cc_sizeid, in send_start()
887 cap->cc_bytes, 32); in send_start()
900 gspca_dev->cam.bulk_nurbs = 1; /* there must be one URB only */ in sd_isoc_init()
901 sd->do_ctrl = 0; in sd_isoc_init()
902 gspca_dev->cam.bulk_size = gspca_dev->pixfmt.width * in sd_isoc_init()
903 gspca_dev->pixfmt.height + 8; in sd_isoc_init()
917 switch (sd->sensor) { in sd_start()
945 if (sd->type != Creative_live_motion) in sd_start()
956 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; in sd_start()
1011 if (sd->sensor == SENSOR_MT9V111) in sd_start()
1014 sd->do_ctrl = 1; /* set the exposure */ in sd_start()
1016 return gspca_dev->usb_err; in sd_start()
1023 if (sd->sensor == SENSOR_MT9V111) in sd_stopN()
1035 if (!sd->do_ctrl || gspca_dev->cam.bulk_nurbs != 0) in sd_dq_callback()
1037 sd->do_ctrl = 0; in sd_dq_callback()
1039 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure), in sd_dq_callback()
1040 v4l2_ctrl_g_ctrl(sd->gain)); in sd_dq_callback()
1042 gspca_dev->cam.bulk_nurbs = 1; in sd_dq_callback()
1043 ret = usb_submit_urb(gspca_dev->urb[0], GFP_KERNEL); in sd_dq_callback()
1057 if (sd->do_ctrl) in sd_pkt_scan()
1058 gspca_dev->cam.bulk_nurbs = 0; in sd_pkt_scan()
1060 gspca_frame_add(gspca_dev, INTER_PACKET, data, len - 8); in sd_pkt_scan()
1067 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
1070 gspca_dev->usb_err = 0; in sd_s_ctrl()
1072 if (!gspca_dev->streaming) in sd_s_ctrl()
1075 switch (ctrl->id) { in sd_s_ctrl()
1077 setexposure(gspca_dev, ctrl->val, sd->gain->val); in sd_s_ctrl()
1080 return gspca_dev->usb_err; in sd_s_ctrl()
1089 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
1092 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
1094 sd->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1096 sd->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
1099 if (hdl->error) { in sd_init_controls()
1101 return hdl->error; in sd_init_controls()
1103 v4l2_ctrl_cluster(2, &sd->exposure); in sd_init_controls()
1107 /* sub-driver description */
1121 #define ST(sensor, type) \ argument
1122 .driver_info = (SENSOR_ ## sensor << 8) \
1136 /* -- device connect -- */