Lines Matching +full:scaled +full:- +full:output +full:- +full:hz
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ov534-ov7xxx gspca driver
7 * Copyright (C) 2009 Jean-Francois Moine http://moinejf.free.fr
14 * PS3 Eye camera - brightness, contrast, awb, agc, aec controls
16 * PS3 Eye camera - FPS range extended by Joseph Howse
26 #include <linux/fixp-arith.h>
27 #include <media/v4l2-ctrls.h>
147 /* comments from the ms-win file apollo7670.set */
309 {0x41, 0x38}, /* jfm: auto sharpness + auto de-noise */
360 {0x8d, 0x1c}, /* output YUV */
368 {0x57, 0x00}, /* H-size[9]=0 */
369 {0x5c, 0x00}, /* output size[9:8]=0 */
370 {0x5a, 0xa0}, /* output H=640/4 */
371 {0x5b, 0x78}, /* output V=480/4 */
395 {0x8d, 0x1c}, /* output YUV */
397 {0xc2, 0x4c}, /* output YUV and Enable DCW */
400 {0x1d, 0x48}, /* output YUV422 */
407 {0x57, 0x00}, /* H-size[9]=0 */
408 {0x5c, 0x00}, /* DCW output size[9:8]=0 */
409 {0x5a, 0x50}, /* DCW output H=320/4 */
410 {0x5b, 0x3c}, /* DCW output V=240/4 */
486 { 0x63, 0xaa }, /* AWB - was e0 */
547 { 0x8e, 0x00 }, /* De-noise threshold */
660 struct usb_device *udev = gspca_dev->dev; in ov534_reg_write()
663 if (gspca_dev->usb_err < 0) in ov534_reg_write()
667 gspca_dev->usb_buf[0] = val; in ov534_reg_write()
672 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); in ov534_reg_write()
675 gspca_dev->usb_err = ret; in ov534_reg_write()
681 struct usb_device *udev = gspca_dev->dev; in ov534_reg_read()
684 if (gspca_dev->usb_err < 0) in ov534_reg_read()
690 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); in ov534_reg_read()
692 reg, gspca_dev->usb_buf[0]); in ov534_reg_read()
695 gspca_dev->usb_err = ret; in ov534_reg_read()
700 gspca_dev->usb_buf[0] = 0; in ov534_reg_read()
702 return gspca_dev->usb_buf[0]; in ov534_reg_read()
706 * (direction and output)? */
765 gspca_dev->usb_err = -EIO; in sccb_reg_write()
783 /* output a bridge sequence (reg - val) */
787 while (--len >= 0) { in reg_w_array()
793 /* output a sensor sequence (reg - val) */
797 while (--len >= 0) { in sccb_w_array()
841 if (sd->sensor != SENSOR_OV772x) in set_frame_rate()
843 if (gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv == 0) { in set_frame_rate()
850 while (--i >= 0) { in set_frame_rate()
851 if (sd->frame_rate >= r->fps) in set_frame_rate()
856 sccb_reg_write(gspca_dev, 0x11, r->r11); in set_frame_rate()
857 sccb_reg_write(gspca_dev, 0x0d, r->r0d); in set_frame_rate()
858 ov534_reg_write(gspca_dev, 0xe5, r->re5); in set_frame_rate()
860 gspca_dbg(gspca_dev, D_PROBE, "frame_rate: %d\n", r->fps); in set_frame_rate()
867 if (sd->sensor == SENSOR_OV767x) { in sethue()
875 * scaled by 0x80. in sethue()
879 * consider the result like in the interval [-1.0, 1.0]. in sethue()
887 huesin = -huesin; in sethue()
902 if (sd->sensor == SENSOR_OV767x) { in setsaturation()
926 if (sd->sensor == SENSOR_OV767x) { in setbrightness()
928 val = 0x80 - val; in setbrightness()
939 if (sd->sensor == SENSOR_OV767x) in setcontrast()
977 if (sd->sensor == SENSOR_OV767x) { in setexposure()
998 if (sd->sensor == SENSOR_OV767x) { in getexposure()
1030 if (sd->sensor == SENSOR_OV772x) in setawb()
1036 if (sd->sensor == SENSOR_OV772x) in setawb()
1047 data = sd->sensor == SENSOR_OV767x ? in setaec()
1064 sccb_reg_write(gspca_dev, 0x91, val); /* Auto de-noise threshold */ in setsharpness()
1065 sccb_reg_write(gspca_dev, 0x8e, val); /* De-noise threshold */ in setsharpness()
1073 if (sd->sensor == SENSOR_OV767x) { in sethvflip()
1097 if (sd->sensor == SENSOR_OV767x) { in setlightfreq()
1100 val = 0x9d; /* insert dummy to 25fps for 50Hz */ in setlightfreq()
1113 cam = &gspca_dev->cam; in sd_config()
1115 cam->cam_mode = ov772x_mode; in sd_config()
1116 cam->nmodes = ARRAY_SIZE(ov772x_mode); in sd_config()
1118 sd->frame_rate = DEFAULT_FRAME_RATE; in sd_config()
1125 struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); in ov534_g_volatile_ctrl()
1126 struct gspca_dev *gspca_dev = &sd->gspca_dev; in ov534_g_volatile_ctrl()
1128 switch (ctrl->id) { in ov534_g_volatile_ctrl()
1130 gspca_dev->usb_err = 0; in ov534_g_volatile_ctrl()
1131 if (ctrl->val && sd->gain && gspca_dev->streaming) in ov534_g_volatile_ctrl()
1132 sd->gain->val = getgain(gspca_dev); in ov534_g_volatile_ctrl()
1133 return gspca_dev->usb_err; in ov534_g_volatile_ctrl()
1136 gspca_dev->usb_err = 0; in ov534_g_volatile_ctrl()
1137 if (ctrl->val == V4L2_EXPOSURE_AUTO && sd->exposure && in ov534_g_volatile_ctrl()
1138 gspca_dev->streaming) in ov534_g_volatile_ctrl()
1139 sd->exposure->val = getexposure(gspca_dev); in ov534_g_volatile_ctrl()
1140 return gspca_dev->usb_err; in ov534_g_volatile_ctrl()
1142 return -EINVAL; in ov534_g_volatile_ctrl()
1147 struct sd *sd = container_of(ctrl->handler, struct sd, ctrl_handler); in ov534_s_ctrl()
1148 struct gspca_dev *gspca_dev = &sd->gspca_dev; in ov534_s_ctrl()
1150 gspca_dev->usb_err = 0; in ov534_s_ctrl()
1151 if (!gspca_dev->streaming) in ov534_s_ctrl()
1154 switch (ctrl->id) { in ov534_s_ctrl()
1156 sethue(gspca_dev, ctrl->val); in ov534_s_ctrl()
1159 setsaturation(gspca_dev, ctrl->val); in ov534_s_ctrl()
1162 setbrightness(gspca_dev, ctrl->val); in ov534_s_ctrl()
1165 setcontrast(gspca_dev, ctrl->val); in ov534_s_ctrl()
1169 setagc(gspca_dev, ctrl->val); in ov534_s_ctrl()
1170 if (!gspca_dev->usb_err && !ctrl->val && sd->gain) in ov534_s_ctrl()
1171 setgain(gspca_dev, sd->gain->val); in ov534_s_ctrl()
1174 setawb(gspca_dev, ctrl->val); in ov534_s_ctrl()
1178 setaec(gspca_dev, ctrl->val); in ov534_s_ctrl()
1179 if (!gspca_dev->usb_err && ctrl->val == V4L2_EXPOSURE_MANUAL && in ov534_s_ctrl()
1180 sd->exposure) in ov534_s_ctrl()
1181 setexposure(gspca_dev, sd->exposure->val); in ov534_s_ctrl()
1184 setsharpness(gspca_dev, ctrl->val); in ov534_s_ctrl()
1187 sethvflip(gspca_dev, ctrl->val, sd->vflip->val); in ov534_s_ctrl()
1190 sethvflip(gspca_dev, sd->hflip->val, ctrl->val); in ov534_s_ctrl()
1193 setlightfreq(gspca_dev, ctrl->val); in ov534_s_ctrl()
1196 return gspca_dev->usb_err; in ov534_s_ctrl()
1207 struct v4l2_ctrl_handler *hdl = &sd->ctrl_handler; in sd_init_controls()
1222 if (sd->sensor == SENSOR_OV767x) { in sd_init_controls()
1226 brightness_min = -127; in sd_init_controls()
1250 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
1254 if (sd->sensor == SENSOR_OV772x) in sd_init_controls()
1255 sd->hue = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1256 V4L2_CID_HUE, -90, 90, 1, 0); in sd_init_controls()
1258 sd->saturation = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1261 sd->brightness = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1264 sd->contrast = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1267 if (sd->sensor == SENSOR_OV772x) { in sd_init_controls()
1268 sd->autogain = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1270 sd->gain = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1274 sd->autoexposure = v4l2_ctrl_new_std_menu(hdl, &ov534_ctrl_ops, in sd_init_controls()
1278 sd->exposure = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1282 sd->autowhitebalance = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1285 if (sd->sensor == SENSOR_OV772x) in sd_init_controls()
1286 sd->sharpness = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1289 sd->hflip = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1291 sd->vflip = v4l2_ctrl_new_std(hdl, &ov534_ctrl_ops, in sd_init_controls()
1293 sd->plfreq = v4l2_ctrl_new_std_menu(hdl, &ov534_ctrl_ops, in sd_init_controls()
1298 if (hdl->error) { in sd_init_controls()
1300 return hdl->error; in sd_init_controls()
1303 if (sd->sensor == SENSOR_OV772x) in sd_init_controls()
1304 v4l2_ctrl_auto_cluster(2, &sd->autogain, 0, true); in sd_init_controls()
1306 v4l2_ctrl_auto_cluster(2, &sd->autoexposure, V4L2_EXPOSURE_MANUAL, in sd_init_controls()
1346 sd->sensor = SENSOR_OV767x; in sd_init()
1347 gspca_dev->cam.cam_mode = ov767x_mode; in sd_init()
1348 gspca_dev->cam.nmodes = ARRAY_SIZE(ov767x_mode); in sd_init()
1350 sd->sensor = SENSOR_OV772x; in sd_init()
1351 gspca_dev->cam.bulk = 1; in sd_init()
1352 gspca_dev->cam.bulk_size = 16384; in sd_init()
1353 gspca_dev->cam.bulk_nurbs = 2; in sd_init()
1354 gspca_dev->cam.mode_framerates = ov772x_framerates; in sd_init()
1358 reg_w_array(gspca_dev, bridge_init[sd->sensor].val, in sd_init()
1359 bridge_init[sd->sensor].len); in sd_init()
1361 sccb_w_array(gspca_dev, sensor_init[sd->sensor].val, in sd_init()
1362 sensor_init[sd->sensor].len); in sd_init()
1367 return gspca_dev->usb_err; in sd_init()
1403 /* (from ms-win trace) */ in sd_start()
1404 if (sd->sensor == SENSOR_OV767x) in sd_start()
1408 mode = gspca_dev->curr_mode; /* 0: 320x240, 1: 640x480 */ in sd_start()
1409 reg_w_array(gspca_dev, bridge_start[sd->sensor][mode].val, in sd_start()
1410 bridge_start[sd->sensor][mode].len); in sd_start()
1411 sccb_w_array(gspca_dev, sensor_start[sd->sensor][mode].val, in sd_start()
1412 sensor_start[sd->sensor][mode].len); in sd_start()
1416 if (sd->hue) in sd_start()
1417 sethue(gspca_dev, v4l2_ctrl_g_ctrl(sd->hue)); in sd_start()
1418 setsaturation(gspca_dev, v4l2_ctrl_g_ctrl(sd->saturation)); in sd_start()
1419 if (sd->autogain) in sd_start()
1420 setagc(gspca_dev, v4l2_ctrl_g_ctrl(sd->autogain)); in sd_start()
1421 setawb(gspca_dev, v4l2_ctrl_g_ctrl(sd->autowhitebalance)); in sd_start()
1422 setaec(gspca_dev, v4l2_ctrl_g_ctrl(sd->autoexposure)); in sd_start()
1423 if (sd->gain) in sd_start()
1424 setgain(gspca_dev, v4l2_ctrl_g_ctrl(sd->gain)); in sd_start()
1425 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(sd->exposure)); in sd_start()
1426 setbrightness(gspca_dev, v4l2_ctrl_g_ctrl(sd->brightness)); in sd_start()
1427 setcontrast(gspca_dev, v4l2_ctrl_g_ctrl(sd->contrast)); in sd_start()
1428 if (sd->sharpness) in sd_start()
1429 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in sd_start()
1430 sethvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip), in sd_start()
1431 v4l2_ctrl_g_ctrl(sd->vflip)); in sd_start()
1432 setlightfreq(gspca_dev, v4l2_ctrl_g_ctrl(sd->plfreq)); in sd_start()
1436 return gspca_dev->usb_err; in sd_start()
1464 payload_len = gspca_dev->cam.bulk ? 2048 : 2040; in sd_pkt_scan()
1468 /* Payloads are prefixed with a UVC-style header. We in sd_pkt_scan()
1495 if (this_pts != sd->last_pts || this_fid != sd->last_fid) { in sd_pkt_scan()
1496 if (gspca_dev->last_packet_type == INTER_PACKET) in sd_pkt_scan()
1499 sd->last_pts = this_pts; in sd_pkt_scan()
1500 sd->last_fid = this_fid; in sd_pkt_scan()
1502 data + 12, len - 12); in sd_pkt_scan()
1505 sd->last_pts = 0; in sd_pkt_scan()
1506 if (gspca_dev->pixfmt.pixelformat != V4L2_PIX_FMT_JPEG in sd_pkt_scan()
1507 && gspca_dev->image_len + len - 12 != in sd_pkt_scan()
1508 gspca_dev->pixfmt.sizeimage) { in sd_pkt_scan()
1513 data + 12, len - 12); in sd_pkt_scan()
1518 data + 12, len - 12); in sd_pkt_scan()
1526 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
1529 remaining_len -= len; in sd_pkt_scan()
1538 struct v4l2_captureparm *cp = &parm->parm.capture; in sd_get_streamparm()
1539 struct v4l2_fract *tpf = &cp->timeperframe; in sd_get_streamparm()
1542 tpf->numerator = 1; in sd_get_streamparm()
1543 tpf->denominator = sd->frame_rate; in sd_get_streamparm()
1550 struct v4l2_captureparm *cp = &parm->parm.capture; in sd_set_streamparm()
1551 struct v4l2_fract *tpf = &cp->timeperframe; in sd_set_streamparm()
1554 if (tpf->numerator == 0 || tpf->denominator == 0) in sd_set_streamparm()
1555 sd->frame_rate = DEFAULT_FRAME_RATE; in sd_set_streamparm()
1557 sd->frame_rate = tpf->denominator / tpf->numerator; in sd_set_streamparm()
1559 if (gspca_dev->streaming) in sd_set_streamparm()
1563 tpf->numerator = 1; in sd_set_streamparm()
1564 tpf->denominator = sd->frame_rate; in sd_set_streamparm()
1567 /* sub-driver description */
1580 /* -- module initialisation -- */
1589 /* -- device connect -- */