Lines Matching refs:ov
426 struct usb_ov511 *ov = data; in ov511_read_proc_info() local
430 if (!ov || !ov->dev) in ov511_read_proc_info()
433 sensor_get_picture(ov, &p); in ov511_read_proc_info()
434 sensor_get_exposure(ov, &exp); in ov511_read_proc_info()
440 out += sprintf(out, "custom_id : %d\n", ov->customid); in ov511_read_proc_info()
441 out += sprintf(out, "model : %s\n", ov->desc); in ov511_read_proc_info()
442 out += sprintf(out, "streaming : %s\n", YES_NO(ov->streaming)); in ov511_read_proc_info()
443 out += sprintf(out, "grabbing : %s\n", YES_NO(ov->grabbing)); in ov511_read_proc_info()
444 out += sprintf(out, "compress : %s\n", YES_NO(ov->compress)); in ov511_read_proc_info()
445 out += sprintf(out, "subcapture : %s\n", YES_NO(ov->sub_flag)); in ov511_read_proc_info()
447 ov->subx, ov->suby, ov->subw, ov->subh); in ov511_read_proc_info()
459 ov->frame[i].depth); in ov511_read_proc_info()
461 ov->frame[i].width, ov->frame[i].height); in ov511_read_proc_info()
463 symbolic(v4l1_plist, ov->frame[i].format)); in ov511_read_proc_info()
465 ov->frame[i].data); in ov511_read_proc_info()
467 out += sprintf(out, "snap_enabled : %s\n", YES_NO(ov->snap_enabled)); in ov511_read_proc_info()
469 symbolic(brglist, ov->bridge)); in ov511_read_proc_info()
471 symbolic(senlist, ov->sensor)); in ov511_read_proc_info()
472 out += sprintf(out, "packet_size : %d\n", ov->packet_size); in ov511_read_proc_info()
473 out += sprintf(out, "framebuffer : 0x%p\n", ov->fbuf); in ov511_read_proc_info()
474 out += sprintf(out, "packet_numbering: %d\n", ov->packet_numbering); in ov511_read_proc_info()
475 out += sprintf(out, "topology : %s\n", ov->usb_path); in ov511_read_proc_info()
508 struct usb_ov511 *ov = data; in ov511_read_proc_button() local
510 if (!ov || !ov->dev) in ov511_read_proc_button()
513 status = ov51x_check_snapshot(ov); in ov511_read_proc_button()
517 ov51x_clear_snapshot(ov); in ov511_read_proc_button()
535 create_proc_ov511_cam(struct usb_ov511 *ov) in create_proc_ov511_cam() argument
539 if (!ov511_proc_entry || !ov) in create_proc_ov511_cam()
543 snprintf(dirname, 10, "%d", ov->vdev.minor); in create_proc_ov511_cam()
545 ov->proc_devdir = create_proc_entry(dirname, S_IFDIR, ov511_proc_entry); in create_proc_ov511_cam()
546 if (!ov->proc_devdir) in create_proc_ov511_cam()
548 ov->proc_devdir->owner = THIS_MODULE; in create_proc_ov511_cam()
552 ov->proc_info = create_proc_read_entry("info", S_IFREG|S_IRUGO|S_IWUSR, in create_proc_ov511_cam()
553 ov->proc_devdir, ov511_read_proc_info, ov); in create_proc_ov511_cam()
554 if (!ov->proc_info) in create_proc_ov511_cam()
556 ov->proc_info->owner = THIS_MODULE; in create_proc_ov511_cam()
562 ov->proc_button = create_proc_read_entry("button", in create_proc_ov511_cam()
563 S_IFREG|S_IRUGO|S_IWUSR, ov->proc_devdir, in create_proc_ov511_cam()
564 ov511_read_proc_button, ov); in create_proc_ov511_cam()
565 if (!ov->proc_button) in create_proc_ov511_cam()
567 ov->proc_button->owner = THIS_MODULE; in create_proc_ov511_cam()
573 ov->proc_control = create_proc_entry("control", S_IFREG|S_IRUGO|S_IWUSR, in create_proc_ov511_cam()
574 ov->proc_devdir); in create_proc_ov511_cam()
575 if (!ov->proc_control) { in create_proc_ov511_cam()
579 ov->proc_control->owner = THIS_MODULE; in create_proc_ov511_cam()
580 ov->proc_control->data = ov; in create_proc_ov511_cam()
581 ov->proc_control->proc_fops = &ov511_control_fops; in create_proc_ov511_cam()
586 destroy_proc_ov511_cam(struct usb_ov511 *ov) in destroy_proc_ov511_cam() argument
590 if (!ov || !ov->proc_devdir) in destroy_proc_ov511_cam()
593 snprintf(dirname, 10, "%d", ov->vdev.minor); in destroy_proc_ov511_cam()
596 if (ov->proc_control) { in destroy_proc_ov511_cam()
598 remove_proc_entry("control", ov->proc_devdir); in destroy_proc_ov511_cam()
599 ov->proc_control = NULL; in destroy_proc_ov511_cam()
603 if (ov->proc_button) { in destroy_proc_ov511_cam()
605 remove_proc_entry("button", ov->proc_devdir); in destroy_proc_ov511_cam()
606 ov->proc_button = NULL; in destroy_proc_ov511_cam()
610 if (ov->proc_info) { in destroy_proc_ov511_cam()
612 remove_proc_entry("info", ov->proc_devdir); in destroy_proc_ov511_cam()
613 ov->proc_info = NULL; in destroy_proc_ov511_cam()
619 ov->proc_devdir = NULL; in destroy_proc_ov511_cam()
663 reg_w(struct usb_ov511 *ov, unsigned char reg, unsigned char value) in reg_w() argument
669 down(&ov->cbuf_lock); in reg_w()
670 ov->cbuf[0] = value; in reg_w()
671 rc = usb_control_msg(ov->dev, in reg_w()
672 usb_sndctrlpipe(ov->dev, 0), in reg_w()
673 (ov->bclass == BCL_OV518)?1:2 /* REG_IO */, in reg_w()
675 0, (__u16)reg, &ov->cbuf[0], 1, HZ); in reg_w()
676 up(&ov->cbuf_lock); in reg_w()
687 reg_r(struct usb_ov511 *ov, unsigned char reg) in reg_r() argument
691 down(&ov->cbuf_lock); in reg_r()
692 rc = usb_control_msg(ov->dev, in reg_r()
693 usb_rcvctrlpipe(ov->dev, 0), in reg_r()
694 (ov->bclass == BCL_OV518)?1:3 /* REG_IO */, in reg_r()
696 0, (__u16)reg, &ov->cbuf[0], 1, HZ); in reg_r()
701 rc = ov->cbuf[0]; in reg_r()
702 PDEBUG(5, "0x%02X:0x%02X", reg, ov->cbuf[0]); in reg_r()
705 up(&ov->cbuf_lock); in reg_r()
717 reg_w_mask(struct usb_ov511 *ov, in reg_w_mask() argument
725 ret = reg_r(ov, reg); in reg_w_mask()
734 return (reg_w(ov, reg, newval)); in reg_w_mask()
742 ov518_reg_w32(struct usb_ov511 *ov, unsigned char reg, u32 val, int n) in ov518_reg_w32() argument
748 down(&ov->cbuf_lock); in ov518_reg_w32()
750 *((u32 *)ov->cbuf) = __cpu_to_le32(val); in ov518_reg_w32()
752 rc = usb_control_msg(ov->dev, in ov518_reg_w32()
753 usb_sndctrlpipe(ov->dev, 0), in ov518_reg_w32()
756 0, (__u16)reg, ov->cbuf, n, HZ); in ov518_reg_w32()
757 up(&ov->cbuf_lock); in ov518_reg_w32()
767 ov511_upload_quan_tables(struct usb_ov511 *ov) in ov511_upload_quan_tables() argument
783 rc = reg_w(ov, reg, val0); in ov511_upload_quan_tables()
794 rc = reg_w(ov, reg + OV511_QUANTABLESIZE/2, val0); in ov511_upload_quan_tables()
807 ov518_upload_quan_tables(struct usb_ov511 *ov) in ov518_upload_quan_tables() argument
823 rc = reg_w(ov, reg, val0); in ov518_upload_quan_tables()
834 rc = reg_w(ov, reg + OV518_QUANTABLESIZE/2, val0); in ov518_upload_quan_tables()
846 ov51x_reset(struct usb_ov511 *ov, unsigned char reset_type) in ov51x_reset() argument
851 if (ov->bclass == BCL_OV518) in ov51x_reset()
856 rc = reg_w(ov, R51x_SYS_RESET, reset_type); in ov51x_reset()
857 rc = reg_w(ov, R51x_SYS_RESET, 0); in ov51x_reset()
877 ov518_i2c_write_internal(struct usb_ov511 *ov, in ov518_i2c_write_internal() argument
886 rc = reg_w(ov, R51x_I2C_SADDR_3, reg); in ov518_i2c_write_internal()
890 rc = reg_w(ov, R51x_I2C_DATA, value); in ov518_i2c_write_internal()
894 rc = reg_w(ov, R518_I2C_CTL, 0x01); in ov518_i2c_write_internal()
902 ov511_i2c_write_internal(struct usb_ov511 *ov, in ov511_i2c_write_internal() argument
913 rc = reg_w(ov, R51x_I2C_SADDR_3, reg); in ov511_i2c_write_internal()
917 rc = reg_w(ov, R51x_I2C_DATA, value); in ov511_i2c_write_internal()
921 rc = reg_w(ov, R511_I2C_CTL, 0x01); in ov511_i2c_write_internal()
924 do rc = reg_r(ov, R511_I2C_CTL); in ov511_i2c_write_internal()
932 reg_w(ov, R511_I2C_CTL, 0x10); in ov511_i2c_write_internal()
949 ov518_i2c_read_internal(struct usb_ov511 *ov, unsigned char reg) in ov518_i2c_read_internal() argument
954 rc = reg_w(ov, R51x_I2C_SADDR_2, reg); in ov518_i2c_read_internal()
958 rc = reg_w(ov, R518_I2C_CTL, 0x03); in ov518_i2c_read_internal()
962 rc = reg_w(ov, R518_I2C_CTL, 0x05); in ov518_i2c_read_internal()
965 value = reg_r(ov, R51x_I2C_DATA); in ov518_i2c_read_internal()
975 ov511_i2c_read_internal(struct usb_ov511 *ov, unsigned char reg) in ov511_i2c_read_internal() argument
982 rc = reg_w(ov, R51x_I2C_SADDR_2, reg); in ov511_i2c_read_internal()
986 rc = reg_w(ov, R511_I2C_CTL, 0x03); in ov511_i2c_read_internal()
989 do rc = reg_r(ov, R511_I2C_CTL); in ov511_i2c_read_internal()
997 reg_w(ov, R511_I2C_CTL, 0x10); in ov511_i2c_read_internal()
1008 rc = reg_w(ov, R511_I2C_CTL, 0x05); in ov511_i2c_read_internal()
1011 do rc = reg_r(ov, R511_I2C_CTL); in ov511_i2c_read_internal()
1019 rc = reg_w(ov, R511_I2C_CTL, 0x10); in ov511_i2c_read_internal()
1028 value = reg_r(ov, R51x_I2C_DATA); in ov511_i2c_read_internal()
1033 rc = reg_w(ov, R511_I2C_CTL, 0x05); in ov511_i2c_read_internal()
1042 i2c_r(struct usb_ov511 *ov, unsigned char reg) in i2c_r() argument
1046 down(&ov->i2c_lock); in i2c_r()
1048 if (ov->bclass == BCL_OV518) in i2c_r()
1049 rc = ov518_i2c_read_internal(ov, reg); in i2c_r()
1051 rc = ov511_i2c_read_internal(ov, reg); in i2c_r()
1053 up(&ov->i2c_lock); in i2c_r()
1059 i2c_w(struct usb_ov511 *ov, unsigned char reg, unsigned char value) in i2c_w() argument
1063 down(&ov->i2c_lock); in i2c_w()
1065 if (ov->bclass == BCL_OV518) in i2c_w()
1066 rc = ov518_i2c_write_internal(ov, reg, value); in i2c_w()
1068 rc = ov511_i2c_write_internal(ov, reg, value); in i2c_w()
1070 up(&ov->i2c_lock); in i2c_w()
1077 ov51x_i2c_write_mask_internal(struct usb_ov511 *ov, in ov51x_i2c_write_mask_internal() argument
1088 if (ov->bclass == BCL_OV518) in ov51x_i2c_write_mask_internal()
1089 rc = ov518_i2c_read_internal(ov, reg); in ov51x_i2c_write_mask_internal()
1091 rc = ov511_i2c_read_internal(ov, reg); in ov51x_i2c_write_mask_internal()
1101 if (ov->bclass == BCL_OV518) in ov51x_i2c_write_mask_internal()
1102 return (ov518_i2c_write_internal(ov, reg, newval)); in ov51x_i2c_write_mask_internal()
1104 return (ov511_i2c_write_internal(ov, reg, newval)); in ov51x_i2c_write_mask_internal()
1113 i2c_w_mask(struct usb_ov511 *ov, in i2c_w_mask() argument
1120 down(&ov->i2c_lock); in i2c_w_mask()
1121 rc = ov51x_i2c_write_mask_internal(ov, reg, value, mask); in i2c_w_mask()
1122 up(&ov->i2c_lock); in i2c_w_mask()
1133 i2c_set_slave_internal(struct usb_ov511 *ov, unsigned char slave) in i2c_set_slave_internal() argument
1137 rc = reg_w(ov, R51x_I2C_W_SID, slave); in i2c_set_slave_internal()
1140 rc = reg_w(ov, R51x_I2C_R_SID, slave + 1); in i2c_set_slave_internal()
1148 i2c_w_slave(struct usb_ov511 *ov, in i2c_w_slave() argument
1156 down(&ov->i2c_lock); in i2c_w_slave()
1159 rc = i2c_set_slave_internal(ov, slave); in i2c_w_slave()
1162 rc = ov51x_i2c_write_mask_internal(ov, reg, value, mask); in i2c_w_slave()
1166 if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0) in i2c_w_slave()
1169 up(&ov->i2c_lock); in i2c_w_slave()
1175 i2c_r_slave(struct usb_ov511 *ov, in i2c_r_slave() argument
1181 down(&ov->i2c_lock); in i2c_r_slave()
1184 rc = i2c_set_slave_internal(ov, slave); in i2c_r_slave()
1187 if (ov->bclass == BCL_OV518) in i2c_r_slave()
1188 rc = ov518_i2c_read_internal(ov, reg); in i2c_r_slave()
1190 rc = ov511_i2c_read_internal(ov, reg); in i2c_r_slave()
1194 if (i2c_set_slave_internal(ov, ov->primary_i2c_slave) < 0) in i2c_r_slave()
1197 up(&ov->i2c_lock); in i2c_r_slave()
1203 ov51x_set_slave_ids(struct usb_ov511 *ov, unsigned char sid) in ov51x_set_slave_ids() argument
1207 down(&ov->i2c_lock); in ov51x_set_slave_ids()
1209 rc = i2c_set_slave_internal(ov, sid); in ov51x_set_slave_ids()
1213 rc = ov51x_reset(ov, OV511_RESET_NOREGS); in ov51x_set_slave_ids()
1217 up(&ov->i2c_lock); in ov51x_set_slave_ids()
1222 write_regvals(struct usb_ov511 *ov, struct ov511_regvals * pRegvals) in write_regvals() argument
1228 if ((rc = reg_w(ov, pRegvals->reg, pRegvals->val)) < 0) in write_regvals()
1231 if ((rc = i2c_w(ov, pRegvals->reg, pRegvals->val)) < 0) in write_regvals()
1244 dump_i2c_range(struct usb_ov511 *ov, int reg1, int regn) in dump_i2c_range() argument
1249 rc = i2c_r(ov, i); in dump_i2c_range()
1255 dump_i2c_regs(struct usb_ov511 *ov) in dump_i2c_regs() argument
1258 dump_i2c_range(ov, 0x00, 0x7C); in dump_i2c_regs()
1262 dump_reg_range(struct usb_ov511 *ov, int reg1, int regn) in dump_reg_range() argument
1267 rc = reg_r(ov, i); in dump_reg_range()
1273 ov511_dump_regs(struct usb_ov511 *ov) in ov511_dump_regs() argument
1276 dump_reg_range(ov, 0x10, 0x1f); in ov511_dump_regs()
1278 dump_reg_range(ov, 0x20, 0x23); in ov511_dump_regs()
1280 dump_reg_range(ov, 0x30, 0x31); in ov511_dump_regs()
1282 dump_reg_range(ov, 0x38, 0x39); in ov511_dump_regs()
1283 dump_reg_range(ov, 0x3e, 0x3e); in ov511_dump_regs()
1285 dump_reg_range(ov, 0x40, 0x49); in ov511_dump_regs()
1287 dump_reg_range(ov, 0x50, 0x55); in ov511_dump_regs()
1288 dump_reg_range(ov, 0x5e, 0x5f); in ov511_dump_regs()
1290 dump_reg_range(ov, 0x70, 0x79); in ov511_dump_regs()
1293 dump_reg_range(ov, 0x80, 0x9f); in ov511_dump_regs()
1294 dump_reg_range(ov, 0xa0, 0xbf); in ov511_dump_regs()
1299 ov518_dump_regs(struct usb_ov511 *ov) in ov518_dump_regs() argument
1302 dump_reg_range(ov, 0x20, 0x2f); in ov518_dump_regs()
1304 dump_reg_range(ov, 0x30, 0x3f); in ov518_dump_regs()
1306 dump_reg_range(ov, 0x40, 0x4f); in ov518_dump_regs()
1308 dump_reg_range(ov, 0x50, 0x5f); in ov518_dump_regs()
1310 dump_reg_range(ov, 0x60, 0x6f); in ov518_dump_regs()
1312 dump_reg_range(ov, 0x70, 0x7f); in ov518_dump_regs()
1314 dump_reg_range(ov, 0x80, 0x8f); in ov518_dump_regs()
1316 dump_reg_range(ov, 0x90, 0x9f); in ov518_dump_regs()
1318 dump_reg_range(ov, 0xa0, 0xbf); in ov518_dump_regs()
1320 dump_reg_range(ov, 0xc0, 0xcf); in ov518_dump_regs()
1329 ov51x_stop(struct usb_ov511 *ov) in ov51x_stop() argument
1332 ov->stopped = 1; in ov51x_stop()
1333 if (ov->bclass == BCL_OV518) in ov51x_stop()
1334 return (reg_w_mask(ov, R51x_SYS_RESET, 0x3a, 0x3a)); in ov51x_stop()
1336 return (reg_w(ov, R51x_SYS_RESET, 0x3d)); in ov51x_stop()
1342 ov51x_restart(struct usb_ov511 *ov) in ov51x_restart() argument
1344 if (ov->stopped) { in ov51x_restart()
1346 ov->stopped = 0; in ov51x_restart()
1349 if (ov->bclass == BCL_OV518) in ov51x_restart()
1350 reg_w(ov, 0x2f, 0x80); in ov51x_restart()
1352 return (reg_w(ov, R51x_SYS_RESET, 0x00)); in ov51x_restart()
1360 ov51x_clear_snapshot(struct usb_ov511 *ov) in ov51x_clear_snapshot() argument
1362 if (ov->bclass == BCL_OV511) { in ov51x_clear_snapshot()
1363 reg_w(ov, R51x_SYS_SNAP, 0x00); in ov51x_clear_snapshot()
1364 reg_w(ov, R51x_SYS_SNAP, 0x02); in ov51x_clear_snapshot()
1365 reg_w(ov, R51x_SYS_SNAP, 0x00); in ov51x_clear_snapshot()
1366 } else if (ov->bclass == BCL_OV518) { in ov51x_clear_snapshot()
1377 ov51x_check_snapshot(struct usb_ov511 *ov) in ov51x_check_snapshot() argument
1381 if (ov->bclass == BCL_OV511) { in ov51x_check_snapshot()
1382 ret = reg_r(ov, R51x_SYS_SNAP); in ov51x_check_snapshot()
1388 } else if (ov->bclass == BCL_OV518) { in ov51x_check_snapshot()
1402 init_ov_sensor(struct usb_ov511 *ov) in init_ov_sensor() argument
1407 if (i2c_w(ov, 0x12, 0x80) < 0) return -EIO; in init_ov_sensor()
1413 if ((i2c_r(ov, OV7610_REG_ID_HIGH) == 0x7F) && in init_ov_sensor()
1414 (i2c_r(ov, OV7610_REG_ID_LOW) == 0xA2)) { in init_ov_sensor()
1420 if (i2c_w(ov, 0x12, 0x80) < 0) return -EIO; in init_ov_sensor()
1424 if (i2c_r(ov, 0x00) < 0) return -EIO; in init_ov_sensor()
1436 ov511_set_packet_size(struct usb_ov511 *ov, int size) in ov511_set_packet_size() argument
1440 if (ov51x_stop(ov) < 0) in ov511_set_packet_size()
1445 if (ov->bridge == BRG_OV511) { in ov511_set_packet_size()
1455 } else if (ov->bridge == BRG_OV511PLUS) { in ov511_set_packet_size()
1475 if (reg_w(ov, R51x_FIFO_PSIZE, mult) < 0) in ov511_set_packet_size()
1478 if (usb_set_interface(ov->dev, ov->iface, alt) < 0) { in ov511_set_packet_size()
1483 if (ov51x_reset(ov, OV511_RESET_NOREGS) < 0) in ov511_set_packet_size()
1486 ov->packet_size = size; in ov511_set_packet_size()
1488 if (ov51x_restart(ov) < 0) in ov511_set_packet_size()
1498 ov518_set_packet_size(struct usb_ov511 *ov, int size) in ov518_set_packet_size() argument
1502 if (ov51x_stop(ov) < 0) in ov518_set_packet_size()
1505 if (ov->bclass == BCL_OV518) { in ov518_set_packet_size()
1525 ov->packet_size = size; in ov518_set_packet_size()
1528 ov518_reg_w32(ov, 0x30, size, 2); in ov518_set_packet_size()
1530 if (ov->packet_numbering) in ov518_set_packet_size()
1531 ++ov->packet_size; in ov518_set_packet_size()
1534 if (usb_set_interface(ov->dev, ov->iface, alt) < 0) { in ov518_set_packet_size()
1540 if (reg_w(ov, 0x2f, 0x80) < 0) in ov518_set_packet_size()
1543 if (ov51x_restart(ov) < 0) in ov518_set_packet_size()
1546 if (ov51x_reset(ov, OV511_RESET_NOREGS) < 0) in ov518_set_packet_size()
1554 ov511_init_compression(struct usb_ov511 *ov) in ov511_init_compression() argument
1558 if (!ov->compress_inited) { in ov511_init_compression()
1559 reg_w(ov, 0x70, phy); in ov511_init_compression()
1560 reg_w(ov, 0x71, phuv); in ov511_init_compression()
1561 reg_w(ov, 0x72, pvy); in ov511_init_compression()
1562 reg_w(ov, 0x73, pvuv); in ov511_init_compression()
1563 reg_w(ov, 0x74, qhy); in ov511_init_compression()
1564 reg_w(ov, 0x75, qhuv); in ov511_init_compression()
1565 reg_w(ov, 0x76, qvy); in ov511_init_compression()
1566 reg_w(ov, 0x77, qvuv); in ov511_init_compression()
1568 if (ov511_upload_quan_tables(ov) < 0) { in ov511_init_compression()
1575 ov->compress_inited = 1; in ov511_init_compression()
1582 ov518_init_compression(struct usb_ov511 *ov) in ov518_init_compression() argument
1586 if (!ov->compress_inited) { in ov518_init_compression()
1587 if (ov518_upload_quan_tables(ov) < 0) { in ov518_init_compression()
1594 ov->compress_inited = 1; in ov518_init_compression()
1603 sensor_set_contrast(struct usb_ov511 *ov, unsigned short val) in sensor_set_contrast() argument
1609 if (ov->stop_during_set) in sensor_set_contrast()
1610 if (ov51x_stop(ov) < 0) in sensor_set_contrast()
1613 switch (ov->sensor) { in sensor_set_contrast()
1617 rc = i2c_w(ov, OV7610_REG_CNT, val >> 8); in sensor_set_contrast()
1624 rc = i2c_w_mask(ov, OV7610_REG_CNT, val >> 12, 0x0f); in sensor_set_contrast()
1637 rc = i2c_w(ov, 0x64, ctab[val>>12]); in sensor_set_contrast()
1644 rc = i2c_w(ov, 0x0b, val >> 9); in sensor_set_contrast()
1658 ov->contrast = val; in sensor_set_contrast()
1660 if (ov51x_restart(ov) < 0) in sensor_set_contrast()
1668 sensor_get_contrast(struct usb_ov511 *ov, unsigned short *val) in sensor_get_contrast() argument
1672 switch (ov->sensor) { in sensor_get_contrast()
1675 rc = i2c_r(ov, OV7610_REG_CNT); in sensor_get_contrast()
1682 rc = i2c_r(ov, OV7610_REG_CNT); in sensor_get_contrast()
1690 rc = i2c_r(ov, 0x64); in sensor_get_contrast()
1697 *val = ov->contrast; in sensor_get_contrast()
1705 ov->contrast = *val; in sensor_get_contrast()
1714 sensor_set_brightness(struct usb_ov511 *ov, unsigned short val) in sensor_set_brightness() argument
1720 if (ov->stop_during_set) in sensor_set_brightness()
1721 if (ov51x_stop(ov) < 0) in sensor_set_brightness()
1724 switch (ov->sensor) { in sensor_set_brightness()
1729 rc = i2c_w(ov, OV7610_REG_BRT, val >> 8); in sensor_set_brightness()
1735 if (!ov->auto_brt) { in sensor_set_brightness()
1736 rc = i2c_w(ov, OV7610_REG_BRT, val >> 8); in sensor_set_brightness()
1742 rc = i2c_w(ov, 0x0a, val >> 8); in sensor_set_brightness()
1753 ov->brightness = val; in sensor_set_brightness()
1755 if (ov51x_restart(ov) < 0) in sensor_set_brightness()
1763 sensor_get_brightness(struct usb_ov511 *ov, unsigned short *val) in sensor_get_brightness() argument
1767 switch (ov->sensor) { in sensor_get_brightness()
1773 rc = i2c_r(ov, OV7610_REG_BRT); in sensor_get_brightness()
1780 *val = ov->brightness; in sensor_get_brightness()
1788 ov->brightness = *val; in sensor_get_brightness()
1797 sensor_set_saturation(struct usb_ov511 *ov, unsigned short val) in sensor_set_saturation() argument
1803 if (ov->stop_during_set) in sensor_set_saturation()
1804 if (ov51x_stop(ov) < 0) in sensor_set_saturation()
1807 switch (ov->sensor) { in sensor_set_saturation()
1812 rc = i2c_w(ov, OV7610_REG_SAT, val >> 8); in sensor_set_saturation()
1821 rc = i2c_w(ov, OV7610_REG_SAT, val >> 8); in sensor_set_saturation()
1826 rc = i2c_w(ov, 0x0c, val >> 9); in sensor_set_saturation()
1837 ov->colour = val; in sensor_set_saturation()
1839 if (ov51x_restart(ov) < 0) in sensor_set_saturation()
1847 sensor_get_saturation(struct usb_ov511 *ov, unsigned short *val) in sensor_get_saturation() argument
1851 switch (ov->sensor) { in sensor_get_saturation()
1856 rc = i2c_r(ov, OV7610_REG_SAT); in sensor_get_saturation()
1869 rc = i2c_r(ov, OV7610_REG_SAT); in sensor_get_saturation()
1876 *val = ov->colour; in sensor_get_saturation()
1884 ov->colour = *val; in sensor_get_saturation()
1893 sensor_set_hue(struct usb_ov511 *ov, unsigned short val) in sensor_set_hue() argument
1899 if (ov->stop_during_set) in sensor_set_hue()
1900 if (ov51x_stop(ov) < 0) in sensor_set_hue()
1903 switch (ov->sensor) { in sensor_set_hue()
1907 rc = i2c_w(ov, OV7610_REG_RED, 0xFF - (val >> 8)); in sensor_set_hue()
1911 rc = i2c_w(ov, OV7610_REG_BLUE, val >> 8); in sensor_set_hue()
1918 rc = i2c_w(ov, 0x7a, (unsigned char)(val >> 8) + 0xb); in sensor_set_hue()
1922 rc = i2c_w(ov, 0x79, (unsigned char)(val >> 8) + 0xb); in sensor_set_hue()
1928 rc = i2c_w(ov, 0x0d, (val + 32768) >> 8); in sensor_set_hue()
1939 ov->hue = val; in sensor_set_hue()
1941 if (ov51x_restart(ov) < 0) in sensor_set_hue()
1949 sensor_get_hue(struct usb_ov511 *ov, unsigned short *val) in sensor_get_hue() argument
1953 switch (ov->sensor) { in sensor_get_hue()
1957 rc = i2c_r(ov, OV7610_REG_BLUE); in sensor_get_hue()
1964 rc = i2c_r(ov, 0x7a); in sensor_get_hue()
1971 *val = ov->hue; in sensor_get_hue()
1979 ov->hue = *val; in sensor_get_hue()
1987 sensor_set_picture(struct usb_ov511 *ov, struct video_picture *p) in sensor_set_picture() argument
1993 ov->whiteness = p->whiteness; in sensor_set_picture()
1998 rc = sensor_set_contrast(ov, p->contrast); in sensor_set_picture()
2002 rc = sensor_set_brightness(ov, p->brightness); in sensor_set_picture()
2006 rc = sensor_set_saturation(ov, p->colour); in sensor_set_picture()
2010 rc = sensor_set_hue(ov, p->hue); in sensor_set_picture()
2018 sensor_get_picture(struct usb_ov511 *ov, struct video_picture *p) in sensor_get_picture() argument
2027 rc = sensor_get_contrast(ov, &(p->contrast)); in sensor_get_picture()
2031 rc = sensor_get_brightness(ov, &(p->brightness)); in sensor_get_picture()
2035 rc = sensor_get_saturation(ov, &(p->colour)); in sensor_get_picture()
2039 rc = sensor_get_hue(ov, &(p->hue)); in sensor_get_picture()
2053 sensor_set_exposure(struct usb_ov511 *ov, unsigned char val) in sensor_set_exposure() argument
2059 if (ov->stop_during_set) in sensor_set_exposure()
2060 if (ov51x_stop(ov) < 0) in sensor_set_exposure()
2063 switch (ov->sensor) { in sensor_set_exposure()
2070 rc = i2c_w(ov, 0x10, val); in sensor_set_exposure()
2086 ov->exposure = val; in sensor_set_exposure()
2088 if (ov51x_restart(ov) < 0) in sensor_set_exposure()
2097 sensor_get_exposure(struct usb_ov511 *ov, unsigned char *val) in sensor_get_exposure() argument
2101 switch (ov->sensor) { in sensor_get_exposure()
2108 rc = i2c_r(ov, 0x10); in sensor_get_exposure()
2126 ov->exposure = *val; in sensor_get_exposure()
2134 ov51x_led_control(struct usb_ov511 *ov, int enable) in ov51x_led_control() argument
2138 if (ov->bridge == BRG_OV511PLUS) in ov51x_led_control()
2139 reg_w(ov, R511_SYS_LED_CTL, enable ? 1 : 0); in ov51x_led_control()
2140 else if (ov->bclass == BCL_OV518) in ov51x_led_control()
2141 reg_w_mask(ov, R518_GPIO_OUT, enable ? 0x02 : 0x00, 0x02); in ov51x_led_control()
2156 sensor_set_light_freq(struct usb_ov511 *ov, int freq) in sensor_set_light_freq() argument
2171 switch (ov->sensor) { in sensor_set_light_freq()
2173 i2c_w_mask(ov, 0x2a, sixty?0x00:0x80, 0x80); in sensor_set_light_freq()
2174 i2c_w(ov, 0x2b, sixty?0x00:0xac); in sensor_set_light_freq()
2175 i2c_w_mask(ov, 0x13, 0x10, 0x10); in sensor_set_light_freq()
2176 i2c_w_mask(ov, 0x13, 0x00, 0x10); in sensor_set_light_freq()
2181 i2c_w_mask(ov, 0x2a, sixty?0x00:0x80, 0x80); in sensor_set_light_freq()
2182 i2c_w(ov, 0x2b, sixty?0x00:0xac); in sensor_set_light_freq()
2183 i2c_w_mask(ov, 0x76, 0x01, 0x01); in sensor_set_light_freq()
2187 i2c_w(ov, 0x2b, sixty?0xa8:0x28); in sensor_set_light_freq()
2188 i2c_w(ov, 0x2a, sixty?0x84:0xa4); in sensor_set_light_freq()
2200 ov->lightfreq = freq; in sensor_set_light_freq()
2215 sensor_set_banding_filter(struct usb_ov511 *ov, int enable) in sensor_set_banding_filter() argument
2221 if (ov->sensor == SEN_KS0127 || ov->sensor == SEN_KS0127B in sensor_set_banding_filter()
2222 || ov->sensor == SEN_SAA7111A) { in sensor_set_banding_filter()
2227 rc = i2c_w_mask(ov, 0x2d, enable?0x04:0x00, 0x04); in sensor_set_banding_filter()
2231 ov->bandfilt = enable; in sensor_set_banding_filter()
2243 sensor_set_auto_brightness(struct usb_ov511 *ov, int enable) in sensor_set_auto_brightness() argument
2249 if (ov->sensor == SEN_KS0127 || ov->sensor == SEN_KS0127B in sensor_set_auto_brightness()
2250 || ov->sensor == SEN_SAA7111A) { in sensor_set_auto_brightness()
2255 rc = i2c_w_mask(ov, 0x2d, enable?0x10:0x00, 0x10); in sensor_set_auto_brightness()
2259 ov->auto_brt = enable; in sensor_set_auto_brightness()
2271 sensor_set_auto_exposure(struct usb_ov511 *ov, int enable) in sensor_set_auto_exposure() argument
2275 switch (ov->sensor) { in sensor_set_auto_exposure()
2277 i2c_w_mask(ov, 0x29, enable?0x00:0x80, 0x80); in sensor_set_auto_exposure()
2283 i2c_w_mask(ov, 0x13, enable?0x01:0x00, 0x01); in sensor_set_auto_exposure()
2286 i2c_w_mask(ov, 0x28, enable?0x00:0x10, 0x10); in sensor_set_auto_exposure()
2298 ov->auto_exp = enable; in sensor_set_auto_exposure()
2311 sensor_set_backlight(struct usb_ov511 *ov, int enable) in sensor_set_backlight() argument
2315 switch (ov->sensor) { in sensor_set_backlight()
2318 i2c_w_mask(ov, 0x68, enable?0xe0:0xc0, 0xe0); in sensor_set_backlight()
2319 i2c_w_mask(ov, 0x29, enable?0x08:0x00, 0x08); in sensor_set_backlight()
2320 i2c_w_mask(ov, 0x28, enable?0x02:0x00, 0x02); in sensor_set_backlight()
2323 i2c_w_mask(ov, 0x4e, enable?0xe0:0xc0, 0xe0); in sensor_set_backlight()
2324 i2c_w_mask(ov, 0x29, enable?0x08:0x00, 0x08); in sensor_set_backlight()
2325 i2c_w_mask(ov, 0x0e, enable?0x80:0x00, 0x80); in sensor_set_backlight()
2328 i2c_w_mask(ov, 0x4e, enable?0x80:0x60, 0xe0); in sensor_set_backlight()
2329 i2c_w_mask(ov, 0x29, enable?0x08:0x00, 0x08); in sensor_set_backlight()
2330 i2c_w_mask(ov, 0x28, enable?0x02:0x00, 0x02); in sensor_set_backlight()
2344 ov->backlight = enable; in sensor_set_backlight()
2350 sensor_set_mirror(struct usb_ov511 *ov, int enable) in sensor_set_mirror() argument
2354 switch (ov->sensor) { in sensor_set_mirror()
2361 i2c_w_mask(ov, 0x12, enable?0x40:0x00, 0x40); in sensor_set_mirror()
2373 ov->mirror = enable; in sensor_set_mirror()
2409 mode_init_ov_sensor_regs(struct usb_ov511 *ov, int width, int height, in mode_init_ov_sensor_regs() argument
2416 switch (ov->sensor) { in mode_init_ov_sensor_regs()
2418 i2c_w(ov, 0x14, qvga?0x24:0x04); in mode_init_ov_sensor_regs()
2421 i2c_w_mask(ov, 0x28, qvga?0x00:0x20, 0x20); in mode_init_ov_sensor_regs()
2422 i2c_w(ov, 0x24, 0x10); in mode_init_ov_sensor_regs()
2423 i2c_w(ov, 0x25, qvga?0x40:0x8a); in mode_init_ov_sensor_regs()
2424 i2c_w(ov, 0x2f, qvga?0x30:0xb0); in mode_init_ov_sensor_regs()
2425 i2c_w(ov, 0x35, qvga?0x1c:0x9c); in mode_init_ov_sensor_regs()
2430 i2c_w(ov, 0x14, qvga?0xa4:0x84); in mode_init_ov_sensor_regs()
2431 i2c_w_mask(ov, 0x28, qvga?0x00:0x20, 0x20); in mode_init_ov_sensor_regs()
2432 i2c_w(ov, 0x24, qvga?0x20:0x3a); in mode_init_ov_sensor_regs()
2433 i2c_w(ov, 0x25, qvga?0x30:0x60); in mode_init_ov_sensor_regs()
2434 i2c_w_mask(ov, 0x2d, qvga?0x40:0x00, 0x40); in mode_init_ov_sensor_regs()
2435 i2c_w_mask(ov, 0x67, qvga?0xf0:0x90, 0xf0); in mode_init_ov_sensor_regs()
2436 i2c_w_mask(ov, 0x74, qvga?0x20:0x00, 0x20); in mode_init_ov_sensor_regs()
2440 i2c_w(ov, 0x14, qvga?0xa4:0x84); in mode_init_ov_sensor_regs()
2443 i2c_w_mask(ov, 0x28, qvga?0x00:0x20, 0x20); in mode_init_ov_sensor_regs()
2444 i2c_w(ov, 0x24, qvga?0x20:0x3a); in mode_init_ov_sensor_regs()
2445 i2c_w(ov, 0x25, qvga?0x30:0x60); in mode_init_ov_sensor_regs()
2446 i2c_w_mask(ov, 0x2d, qvga?0x40:0x00, 0x40); in mode_init_ov_sensor_regs()
2447 i2c_w_mask(ov, 0x67, qvga?0xb0:0x90, 0xf0); in mode_init_ov_sensor_regs()
2448 i2c_w_mask(ov, 0x74, qvga?0x20:0x00, 0x20); in mode_init_ov_sensor_regs()
2452 i2c_w(ov, 0x14, qvga?0x24:0x04); in mode_init_ov_sensor_regs()
2455 i2c_w(ov, 0x14, qvga?0xa0:0x80); in mode_init_ov_sensor_regs()
2465 if (ov->sensor == SEN_OV7610 || ov->sensor == SEN_OV76BE) { in mode_init_ov_sensor_regs()
2467 i2c_w_mask(ov, 0x0e, 0x40, 0x40); in mode_init_ov_sensor_regs()
2470 if (ov->sensor == SEN_OV6630 && ov->bridge == BRG_OV518 in mode_init_ov_sensor_regs()
2472 i2c_w_mask(ov, 0x12, 0x00, 0x10); in mode_init_ov_sensor_regs()
2473 i2c_w_mask(ov, 0x13, 0x00, 0x20); in mode_init_ov_sensor_regs()
2475 i2c_w_mask(ov, 0x13, 0x20, 0x20); in mode_init_ov_sensor_regs()
2478 if (ov->sensor == SEN_OV7610 || ov->sensor == SEN_OV76BE) { in mode_init_ov_sensor_regs()
2480 i2c_w_mask(ov, 0x0e, 0x00, 0x40); in mode_init_ov_sensor_regs()
2489 if (ov->sensor == SEN_OV6630 && ov->bridge == BRG_OV518 in mode_init_ov_sensor_regs()
2491 i2c_w_mask(ov, 0x12, 0x10, 0x10); in mode_init_ov_sensor_regs()
2492 i2c_w_mask(ov, 0x13, 0x20, 0x20); in mode_init_ov_sensor_regs()
2494 i2c_w_mask(ov, 0x13, 0x00, 0x20); in mode_init_ov_sensor_regs()
2504 if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630) in mode_init_ov_sensor_regs()
2508 i2c_w(ov, 0x2a, 0x04); in mode_init_ov_sensor_regs()
2510 if (ov->compress) { in mode_init_ov_sensor_regs()
2521 i2c_w(ov, 0x11, clock); in mode_init_ov_sensor_regs()
2523 i2c_w(ov, 0x2a, 0x84); in mode_init_ov_sensor_regs()
2527 i2c_w(ov, 0x2d, 0x85); in mode_init_ov_sensor_regs()
2531 if (ov->compress) { in mode_init_ov_sensor_regs()
2535 clock = ((sub_flag ? ov->subw * ov->subh in mode_init_ov_sensor_regs()
2545 i2c_w(ov, 0x11, clock); in mode_init_ov_sensor_regs()
2551 i2c_w(ov, 0x16, framedrop); in mode_init_ov_sensor_regs()
2554 i2c_w_mask(ov, 0x12, (testpat?0x02:0x00), 0x02); in mode_init_ov_sensor_regs()
2557 i2c_w_mask(ov, 0x12, 0x04, 0x04); in mode_init_ov_sensor_regs()
2562 if (ov->sensor == SEN_OV7610 || ov->sensor == SEN_OV76BE) { in mode_init_ov_sensor_regs()
2564 i2c_w(ov, 0x35, 0x9e); in mode_init_ov_sensor_regs()
2566 i2c_w(ov, 0x35, 0x1e); in mode_init_ov_sensor_regs()
2573 set_ov_sensor_window(struct usb_ov511 *ov, int width, int height, int mode, in set_ov_sensor_window() argument
2582 switch (ov->sensor) { in set_ov_sensor_window()
2606 if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630) { in set_ov_sensor_window()
2609 || ov->bclass == BCL_OV518) { /* CIF */ in set_ov_sensor_window()
2610 ret = mode_init_ov_sensor_regs(ov, width, height, in set_ov_sensor_window()
2622 ret = mode_init_ov_sensor_regs(ov, width, height, in set_ov_sensor_window()
2631 ret = mode_init_ov_sensor_regs(ov, width, height, in set_ov_sensor_window()
2643 ret = mode_init_ov_sensor_regs(ov, width, height, in set_ov_sensor_window()
2659 i2c_w(ov, 0x17, hwsbase+(ov->subx>>hwscale)); in set_ov_sensor_window()
2660 i2c_w(ov, 0x18, hwebase+((ov->subx+ov->subw)>>hwscale)); in set_ov_sensor_window()
2661 i2c_w(ov, 0x19, vwsbase+(ov->suby>>vwscale)); in set_ov_sensor_window()
2662 i2c_w(ov, 0x1a, vwebase+((ov->suby+ov->subh)>>vwscale)); in set_ov_sensor_window()
2664 i2c_w(ov, 0x17, hwsbase + hoffset); in set_ov_sensor_window()
2665 i2c_w(ov, 0x18, hwebase + hoffset + (hwsize>>hwscale)); in set_ov_sensor_window()
2666 i2c_w(ov, 0x19, vwsbase + voffset); in set_ov_sensor_window()
2667 i2c_w(ov, 0x1a, vwebase + voffset + (vwsize>>vwscale)); in set_ov_sensor_window()
2672 dump_i2c_regs(ov); in set_ov_sensor_window()
2683 ov511_mode_init_regs(struct usb_ov511 *ov, in ov511_mode_init_regs() argument
2689 width = ov->subw; in ov511_mode_init_regs()
2690 height = ov->subh; in ov511_mode_init_regs()
2698 if (ov->sensor == SEN_SAA7111A) { in ov511_mode_init_regs()
2717 if (width < ov->minwidth || height < ov->minheight) { in ov511_mode_init_regs()
2722 if (ov51x_stop(ov) < 0) in ov511_mode_init_regs()
2726 reg_w(ov, R511_CAM_UV_EN, 0x00); in ov511_mode_init_regs()
2727 reg_w(ov, R511_SNAP_UV_EN, 0x00); in ov511_mode_init_regs()
2728 reg_w(ov, R511_SNAP_OPTS, 0x01); in ov511_mode_init_regs()
2730 reg_w(ov, R511_CAM_UV_EN, 0x01); in ov511_mode_init_regs()
2731 reg_w(ov, R511_SNAP_UV_EN, 0x01); in ov511_mode_init_regs()
2732 reg_w(ov, R511_SNAP_OPTS, 0x03); in ov511_mode_init_regs()
2741 reg_w(ov, R511_CAM_PXCNT, hsegs); in ov511_mode_init_regs()
2742 reg_w(ov, R511_CAM_LNCNT, vsegs); in ov511_mode_init_regs()
2743 reg_w(ov, R511_CAM_PXDIV, 0x00); in ov511_mode_init_regs()
2744 reg_w(ov, R511_CAM_LNDIV, 0x00); in ov511_mode_init_regs()
2747 reg_w(ov, R511_CAM_OPTS, 0x03); in ov511_mode_init_regs()
2750 reg_w(ov, R511_SNAP_PXCNT, hsegs); in ov511_mode_init_regs()
2751 reg_w(ov, R511_SNAP_LNCNT, vsegs); in ov511_mode_init_regs()
2752 reg_w(ov, R511_SNAP_PXDIV, 0x00); in ov511_mode_init_regs()
2753 reg_w(ov, R511_SNAP_LNDIV, 0x00); in ov511_mode_init_regs()
2755 if (ov->compress) { in ov511_mode_init_regs()
2757 reg_w(ov, R511_COMP_EN, 0x07); in ov511_mode_init_regs()
2758 reg_w(ov, R511_COMP_LUT_EN, 0x03); in ov511_mode_init_regs()
2759 ov51x_reset(ov, OV511_RESET_OMNICE); in ov511_mode_init_regs()
2762 if (ov51x_restart(ov) < 0) in ov511_mode_init_regs()
2776 ov518_mode_init_regs(struct usb_ov511 *ov, in ov518_mode_init_regs() argument
2782 width = ov->subw; in ov518_mode_init_regs()
2783 height = ov->subh; in ov518_mode_init_regs()
2794 if (width < ov->minwidth || height < ov->minheight) { in ov518_mode_init_regs()
2808 if (ov51x_stop(ov) < 0) in ov518_mode_init_regs()
2813 reg_w(ov, 0x2b, 0); in ov518_mode_init_regs()
2814 reg_w(ov, 0x2c, 0); in ov518_mode_init_regs()
2815 reg_w(ov, 0x2d, 0); in ov518_mode_init_regs()
2816 reg_w(ov, 0x2e, 0); in ov518_mode_init_regs()
2817 reg_w(ov, 0x3b, 0); in ov518_mode_init_regs()
2818 reg_w(ov, 0x3c, 0); in ov518_mode_init_regs()
2819 reg_w(ov, 0x3d, 0); in ov518_mode_init_regs()
2820 reg_w(ov, 0x3e, 0); in ov518_mode_init_regs()
2822 if (ov->bridge == BRG_OV518 && ov518_color) { in ov518_mode_init_regs()
2824 i2c_w_mask(ov, 0x15, 0x00, 0x01); in ov518_mode_init_regs()
2828 reg_w_mask(ov, 0x20, 0x00, 0x08); in ov518_mode_init_regs()
2831 reg_w_mask(ov, 0x28, 0x00, 0xf0); in ov518_mode_init_regs()
2832 reg_w_mask(ov, 0x38, 0x00, 0xf0); in ov518_mode_init_regs()
2835 reg_w_mask(ov, 0x20, 0x08, 0x08); in ov518_mode_init_regs()
2838 reg_w_mask(ov, 0x28, 0x80, 0xf0); in ov518_mode_init_regs()
2839 reg_w_mask(ov, 0x38, 0x80, 0xf0); in ov518_mode_init_regs()
2842 reg_w(ov, 0x28, (mode == VIDEO_PALETTE_GREY) ? 0x00:0x80); in ov518_mode_init_regs()
2843 reg_w(ov, 0x38, (mode == VIDEO_PALETTE_GREY) ? 0x00:0x80); in ov518_mode_init_regs()
2849 reg_w(ov, 0x29, hsegs); in ov518_mode_init_regs()
2850 reg_w(ov, 0x2a, vsegs); in ov518_mode_init_regs()
2852 reg_w(ov, 0x39, hsegs); in ov518_mode_init_regs()
2853 reg_w(ov, 0x3a, vsegs); in ov518_mode_init_regs()
2856 reg_w(ov, 0x2f, 0x80); in ov518_mode_init_regs()
2861 reg_w(ov, 0x51, 0x02); /* Clock divider; lower==faster */ in ov518_mode_init_regs()
2862 reg_w(ov, 0x22, 0x18); in ov518_mode_init_regs()
2863 reg_w(ov, 0x23, 0xff); in ov518_mode_init_regs()
2865 if (ov->bridge == BRG_OV518PLUS) in ov518_mode_init_regs()
2866 reg_w(ov, 0x21, 0x19); in ov518_mode_init_regs()
2868 reg_w(ov, 0x71, 0x19); /* Compression-related? */ in ov518_mode_init_regs()
2872 i2c_w(ov, 0x54, 0x23); in ov518_mode_init_regs()
2874 reg_w(ov, 0x2f, 0x80); in ov518_mode_init_regs()
2876 if (ov->bridge == BRG_OV518PLUS) { in ov518_mode_init_regs()
2877 reg_w(ov, 0x24, 0x94); in ov518_mode_init_regs()
2878 reg_w(ov, 0x25, 0x90); in ov518_mode_init_regs()
2879 ov518_reg_w32(ov, 0xc4, 400, 2); /* 190h */ in ov518_mode_init_regs()
2880 ov518_reg_w32(ov, 0xc6, 540, 2); /* 21ch */ in ov518_mode_init_regs()
2881 ov518_reg_w32(ov, 0xc7, 540, 2); /* 21ch */ in ov518_mode_init_regs()
2882 ov518_reg_w32(ov, 0xc8, 108, 2); /* 6ch */ in ov518_mode_init_regs()
2883 ov518_reg_w32(ov, 0xca, 131098, 3); /* 2001ah */ in ov518_mode_init_regs()
2884 ov518_reg_w32(ov, 0xcb, 532, 2); /* 214h */ in ov518_mode_init_regs()
2885 ov518_reg_w32(ov, 0xcc, 2400, 2); /* 960h */ in ov518_mode_init_regs()
2886 ov518_reg_w32(ov, 0xcd, 32, 2); /* 20h */ in ov518_mode_init_regs()
2887 ov518_reg_w32(ov, 0xce, 608, 2); /* 260h */ in ov518_mode_init_regs()
2889 reg_w(ov, 0x24, 0x9f); in ov518_mode_init_regs()
2890 reg_w(ov, 0x25, 0x90); in ov518_mode_init_regs()
2891 ov518_reg_w32(ov, 0xc4, 400, 2); /* 190h */ in ov518_mode_init_regs()
2892 ov518_reg_w32(ov, 0xc6, 500, 2); /* 1f4h */ in ov518_mode_init_regs()
2893 ov518_reg_w32(ov, 0xc7, 500, 2); /* 1f4h */ in ov518_mode_init_regs()
2894 ov518_reg_w32(ov, 0xc8, 142, 2); /* 8eh */ in ov518_mode_init_regs()
2895 ov518_reg_w32(ov, 0xca, 131098, 3); /* 2001ah */ in ov518_mode_init_regs()
2896 ov518_reg_w32(ov, 0xcb, 532, 2); /* 214h */ in ov518_mode_init_regs()
2897 ov518_reg_w32(ov, 0xcc, 2000, 2); /* 7d0h */ in ov518_mode_init_regs()
2898 ov518_reg_w32(ov, 0xcd, 32, 2); /* 20h */ in ov518_mode_init_regs()
2899 ov518_reg_w32(ov, 0xce, 608, 2); /* 260h */ in ov518_mode_init_regs()
2902 reg_w(ov, 0x2f, 0x80); in ov518_mode_init_regs()
2904 if (ov51x_restart(ov) < 0) in ov518_mode_init_regs()
2908 if (ov51x_reset(ov, OV511_RESET_NOREGS) < 0) in ov518_mode_init_regs()
2916 mode_init_regs(struct usb_ov511 *ov, in mode_init_regs() argument
2921 if (!ov || !ov->dev) in mode_init_regs()
2924 if (ov->bclass == BCL_OV518) { in mode_init_regs()
2925 rc = ov518_mode_init_regs(ov, width, height, mode, sub_flag); in mode_init_regs()
2927 rc = ov511_mode_init_regs(ov, width, height, mode, sub_flag); in mode_init_regs()
2933 switch (ov->sensor) { in mode_init_regs()
2940 rc = set_ov_sensor_window(ov, width, height, mode, sub_flag); in mode_init_regs()
2951 PDEBUG(1, "SAA status = 0x%02X", i2c_r(ov, 0x1f)); in mode_init_regs()
2962 rc = sensor_set_auto_brightness(ov, ov->auto_brt); in mode_init_regs()
2966 rc = sensor_set_auto_exposure(ov, ov->auto_exp); in mode_init_regs()
2970 rc = sensor_set_banding_filter(ov, bandingfilter); in mode_init_regs()
2974 if (ov->lightfreq) { in mode_init_regs()
2975 rc = sensor_set_light_freq(ov, lightfreq); in mode_init_regs()
2980 rc = sensor_set_backlight(ov, ov->backlight); in mode_init_regs()
2984 rc = sensor_set_mirror(ov, ov->mirror); in mode_init_regs()
2995 ov51x_set_default_params(struct usb_ov511 *ov) in ov51x_set_default_params() argument
3002 ov->frame[i].width = ov->maxwidth; in ov51x_set_default_params()
3003 ov->frame[i].height = ov->maxheight; in ov51x_set_default_params()
3004 ov->frame[i].bytes_read = 0; in ov51x_set_default_params()
3006 ov->frame[i].format = force_palette; in ov51x_set_default_params()
3008 ov->frame[i].format = VIDEO_PALETTE_RGB24; in ov51x_set_default_params()
3010 ov->frame[i].depth = get_depth(ov->frame[i].format); in ov51x_set_default_params()
3013 PDEBUG(3, "%dx%d, %s", ov->maxwidth, ov->maxheight, in ov51x_set_default_params()
3014 symbolic(v4l1_plist, ov->frame[0].format)); in ov51x_set_default_params()
3017 if (mode_init_regs(ov, ov->maxwidth, ov->maxheight, in ov51x_set_default_params()
3018 ov->frame[0].format, 0) < 0) in ov51x_set_default_params()
3032 decoder_set_input(struct usb_ov511 *ov, int input) in decoder_set_input() argument
3036 switch (ov->sensor) { in decoder_set_input()
3040 i2c_w_mask(ov, 0x02, input, 0x07); in decoder_set_input()
3042 i2c_w_mask(ov, 0x09, (input > 3) ? 0x80:0x00, 0x80); in decoder_set_input()
3054 decoder_get_input_name(struct usb_ov511 *ov, int input, char *name) in decoder_get_input_name() argument
3056 switch (ov->sensor) { in decoder_get_input_name()
3076 decoder_set_norm(struct usb_ov511 *ov, int norm) in decoder_set_norm() argument
3080 switch (ov->sensor) { in decoder_set_norm()
3101 i2c_w_mask(ov, 0x08, reg_8, 0xc0); in decoder_set_norm()
3102 i2c_w_mask(ov, 0x0e, reg_e, 0x70); in decoder_set_norm()
3395 request_decompressor(struct usb_ov511 *ov) in request_decompressor() argument
3397 if (!ov) in request_decompressor()
3400 if (ov->decomp_ops) { in request_decompressor()
3408 if (ov->bclass == BCL_OV511) { in request_decompressor()
3411 ov->decomp_ops = ov511_mmx_decomp_ops; in request_decompressor()
3414 ov->decomp_ops = ov511_decomp_ops; in request_decompressor()
3418 } else if (ov->bclass == BCL_OV518) { in request_decompressor()
3421 ov->decomp_ops = ov518_mmx_decomp_ops; in request_decompressor()
3424 ov->decomp_ops = ov518_decomp_ops; in request_decompressor()
3432 if (ov->decomp_ops) { in request_decompressor()
3433 if (!ov->decomp_ops->owner) { in request_decompressor()
3434 ov->decomp_ops = NULL; in request_decompressor()
3438 __MOD_INC_USE_COUNT(ov->decomp_ops->owner); in request_decompressor()
3451 release_decompressor(struct usb_ov511 *ov) in release_decompressor() argument
3455 if (!ov) in release_decompressor()
3460 if (ov->decomp_ops && ov->decomp_ops->owner) { in release_decompressor()
3461 __MOD_DEC_USE_COUNT(ov->decomp_ops->owner); in release_decompressor()
3465 ov->decomp_ops = NULL; in release_decompressor()
3474 decompress(struct usb_ov511 *ov, struct ov511_frame *frame, in decompress() argument
3477 if (!ov->decomp_ops) in decompress()
3478 if (request_decompressor(ov)) in decompress()
3484 && ov->decomp_ops->decomp_400) { in decompress()
3485 int ret = ov->decomp_ops->decomp_400( in decompress()
3494 && ov->decomp_ops->decomp_420) { in decompress()
3495 int ret = ov->decomp_ops->decomp_420( in decompress()
3685 ov51x_postprocess_grey(struct usb_ov511 *ov, struct ov511_frame *frame) in ov51x_postprocess_grey() argument
3688 if (ov->sensor == SEN_SAA7111A && frame->rawheight >= 480) { in ov51x_postprocess_grey()
3690 decompress(ov, frame, frame->rawdata, in ov51x_postprocess_grey()
3700 decompress(ov, frame, frame->rawdata, in ov51x_postprocess_grey()
3712 ov51x_postprocess_yuv420(struct usb_ov511 *ov, struct ov511_frame *frame) in ov51x_postprocess_yuv420() argument
3716 decompress(ov, frame, frame->rawdata, frame->tempdata); in ov51x_postprocess_yuv420()
3721 if (ov->sensor == SEN_SAA7111A && frame->rawheight >= 480) { in ov51x_postprocess_yuv420()
3771 ov51x_postprocess(struct usb_ov511 *ov, struct ov511_frame *frame) in ov51x_postprocess() argument
3775 MAX_DATA_SIZE(ov->maxwidth, ov->maxheight)); in ov51x_postprocess()
3781 ov51x_postprocess_grey(ov, frame); in ov51x_postprocess()
3790 ov51x_postprocess_yuv420(ov, frame); in ov51x_postprocess()
3806 ov511_move_data(struct usb_ov511 *ov, unsigned char *in, int n) in ov511_move_data() argument
3809 int pnum = in[ov->packet_size - 1]; /* Get packet number */ in ov511_move_data()
3810 int max_raw = MAX_RAW_DATA_SIZE(ov->maxwidth, ov->maxheight); in ov511_move_data()
3811 struct ov511_frame *frame = &ov->frame[ov->curframe]; in ov511_move_data()
3842 + MAX_FRAME_SIZE(ov->maxwidth, ov->maxheight)); in ov511_move_data()
3850 ov->curframe, pnum, frame->rawwidth, frame->rawheight, in ov511_move_data()
3854 RESTRICT_TO_RANGE(frame->rawwidth, ov->minwidth, ov->maxwidth); in ov511_move_data()
3855 RESTRICT_TO_RANGE(frame->rawheight, ov->minheight, in ov511_move_data()
3856 ov->maxheight); in ov511_move_data()
3873 nextf = (ov->curframe + 1) % OV511_NUMFRAMES; in ov511_move_data()
3874 if (ov->frame[nextf].grabstate == FRAME_READY in ov511_move_data()
3875 || ov->frame[nextf].grabstate == FRAME_GRABBING) { in ov511_move_data()
3876 ov->curframe = nextf; in ov511_move_data()
3877 ov->frame[nextf].scanstate = STATE_SCANNING; in ov511_move_data()
3883 ov->frame[nextf].grabstate); in ov511_move_data()
3886 ov->curframe = -1; in ov511_move_data()
3896 PDEBUG(4, "Frame start, framenum = %d", ov->curframe); in ov511_move_data()
3980 ov518_move_data(struct usb_ov511 *ov, unsigned char *in, int n) in ov518_move_data() argument
3982 int max_raw = MAX_RAW_DATA_SIZE(ov->maxwidth, ov->maxheight); in ov518_move_data()
3983 struct ov511_frame *frame = &ov->frame[ov->curframe]; in ov518_move_data()
3987 if (ov->packet_numbering) in ov518_move_data()
4003 PDEBUG(4, "Frame start, framenum = %d", ov->curframe); in ov518_move_data()
4012 + MAX_FRAME_SIZE(ov->maxwidth, ov->maxheight)); in ov518_move_data()
4016 ov->curframe, in ov518_move_data()
4025 RESTRICT_TO_RANGE(frame->rawwidth, ov->minwidth, ov->maxwidth); in ov518_move_data()
4026 RESTRICT_TO_RANGE(frame->rawheight, ov->minheight, ov->maxheight); in ov518_move_data()
4043 nextf = (ov->curframe + 1) % OV511_NUMFRAMES; in ov518_move_data()
4044 if (ov->frame[nextf].grabstate == FRAME_READY in ov518_move_data()
4045 || ov->frame[nextf].grabstate == FRAME_GRABBING) { in ov518_move_data()
4046 ov->curframe = nextf; in ov518_move_data()
4047 ov->frame[nextf].scanstate = STATE_SCANNING; in ov518_move_data()
4048 frame = &ov->frame[nextf]; in ov518_move_data()
4054 ov->frame[nextf].grabstate); in ov518_move_data()
4057 ov->curframe = -1; in ov518_move_data()
4137 struct usb_ov511 *ov; in ov51x_isoc_irq() local
4146 ov = sbuf->ov; in ov51x_isoc_irq()
4148 if (!ov || !ov->dev || !ov->user) { in ov51x_isoc_irq()
4153 if (!ov->streaming) { in ov51x_isoc_irq()
4173 if (ov->curframe >= 0) { in ov51x_isoc_irq()
4193 if (ov->bclass == BCL_OV511) in ov51x_isoc_irq()
4194 ov511_move_data(ov, cdata, n); in ov51x_isoc_irq()
4195 else if (ov->bclass == BCL_OV518) in ov51x_isoc_irq()
4196 ov518_move_data(ov, cdata, n); in ov51x_isoc_irq()
4198 err("Unknown bridge device (%d)", ov->bridge); in ov51x_isoc_irq()
4200 } else if (waitqueue_active(&ov->wq)) { in ov51x_isoc_irq()
4201 wake_up_interruptible(&ov->wq); in ov51x_isoc_irq()
4206 urb->dev = ov->dev; in ov51x_isoc_irq()
4220 ov51x_init_isoc(struct usb_ov511 *ov) in ov51x_init_isoc() argument
4227 ov->curframe = -1; in ov51x_init_isoc()
4229 if (ov->bridge == BRG_OV511) { in ov51x_init_isoc()
4237 } else if (ov->bridge == BRG_OV511PLUS) { in ov51x_init_isoc()
4247 } else if (ov->bclass == BCL_OV518) { in ov51x_init_isoc()
4262 if (ov->bclass == BCL_OV518) { in ov51x_init_isoc()
4264 ov518_set_packet_size(ov, 640); in ov51x_init_isoc()
4267 ov518_set_packet_size(ov, packetsize); in ov51x_init_isoc()
4271 ov511_set_packet_size(ov, size); in ov51x_init_isoc()
4274 ov511_set_packet_size(ov, packetsize); in ov51x_init_isoc()
4285 ov->sbuf[n].urb = urb; in ov51x_init_isoc()
4286 urb->dev = ov->dev; in ov51x_init_isoc()
4287 urb->context = &ov->sbuf[n]; in ov51x_init_isoc()
4288 urb->pipe = usb_rcvisocpipe(ov->dev, OV511_ENDPOINT_ADDRESS); in ov51x_init_isoc()
4290 urb->transfer_buffer = ov->sbuf[n].data; in ov51x_init_isoc()
4293 urb->transfer_buffer_length = ov->packet_size * FRAMES_PER_DESC; in ov51x_init_isoc()
4296 urb->iso_frame_desc[fx].offset = ov->packet_size * fx; in ov51x_init_isoc()
4297 urb->iso_frame_desc[fx].length = ov->packet_size; in ov51x_init_isoc()
4301 ov->streaming = 1; in ov51x_init_isoc()
4304 ov->sbuf[n].urb->dev = ov->dev; in ov51x_init_isoc()
4305 err = usb_submit_urb(ov->sbuf[n].urb); in ov51x_init_isoc()
4316 ov51x_unlink_isoc(struct usb_ov511 *ov) in ov51x_unlink_isoc() argument
4322 if (ov->sbuf[n].urb) { in ov51x_unlink_isoc()
4323 usb_unlink_urb(ov->sbuf[n].urb); in ov51x_unlink_isoc()
4324 usb_free_urb(ov->sbuf[n].urb); in ov51x_unlink_isoc()
4325 ov->sbuf[n].urb = NULL; in ov51x_unlink_isoc()
4331 ov51x_stop_isoc(struct usb_ov511 *ov) in ov51x_stop_isoc() argument
4333 if (!ov->streaming || !ov->dev) in ov51x_stop_isoc()
4338 if (ov->bclass == BCL_OV518) in ov51x_stop_isoc()
4339 ov518_set_packet_size(ov, 0); in ov51x_stop_isoc()
4341 ov511_set_packet_size(ov, 0); in ov51x_stop_isoc()
4343 ov->streaming = 0; in ov51x_stop_isoc()
4345 ov51x_unlink_isoc(ov); in ov51x_stop_isoc()
4349 ov51x_new_frame(struct usb_ov511 *ov, int framenum) in ov51x_new_frame() argument
4354 PDEBUG(4, "ov->curframe = %d, framenum = %d", ov->curframe, framenum); in ov51x_new_frame()
4356 if (!ov->dev) in ov51x_new_frame()
4361 if (ov->curframe == -1) { in ov51x_new_frame()
4363 if (ov->frame[newnum].grabstate == FRAME_READY) in ov51x_new_frame()
4368 frame = &ov->frame[framenum]; in ov51x_new_frame()
4377 ov->curframe = framenum; in ov51x_new_frame()
4380 if (frame->width > ov->maxwidth) in ov51x_new_frame()
4381 frame->width = ov->maxwidth; in ov51x_new_frame()
4385 if (frame->height > ov->maxheight) in ov51x_new_frame()
4386 frame->height = ov->maxheight; in ov51x_new_frame()
4405 ov51x_do_dealloc(struct usb_ov511 *ov) in ov51x_do_dealloc() argument
4410 if (ov->fbuf) { in ov51x_do_dealloc()
4411 rvfree(ov->fbuf, OV511_NUMFRAMES in ov51x_do_dealloc()
4412 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight)); in ov51x_do_dealloc()
4413 ov->fbuf = NULL; in ov51x_do_dealloc()
4416 if (ov->rawfbuf) { in ov51x_do_dealloc()
4417 vfree(ov->rawfbuf); in ov51x_do_dealloc()
4418 ov->rawfbuf = NULL; in ov51x_do_dealloc()
4421 if (ov->tempfbuf) { in ov51x_do_dealloc()
4422 vfree(ov->tempfbuf); in ov51x_do_dealloc()
4423 ov->tempfbuf = NULL; in ov51x_do_dealloc()
4427 if (ov->sbuf[i].data) { in ov51x_do_dealloc()
4428 kfree(ov->sbuf[i].data); in ov51x_do_dealloc()
4429 ov->sbuf[i].data = NULL; in ov51x_do_dealloc()
4434 ov->frame[i].data = NULL; in ov51x_do_dealloc()
4435 ov->frame[i].rawdata = NULL; in ov51x_do_dealloc()
4436 ov->frame[i].tempdata = NULL; in ov51x_do_dealloc()
4437 if (ov->frame[i].compbuf) { in ov51x_do_dealloc()
4438 free_page((unsigned long) ov->frame[i].compbuf); in ov51x_do_dealloc()
4439 ov->frame[i].compbuf = NULL; in ov51x_do_dealloc()
4444 ov->buf_state = BUF_NOT_ALLOCATED; in ov51x_do_dealloc()
4449 ov51x_alloc(struct usb_ov511 *ov) in ov51x_alloc() argument
4452 const int w = ov->maxwidth; in ov51x_alloc()
4453 const int h = ov->maxheight; in ov51x_alloc()
4458 down(&ov->buf_lock); in ov51x_alloc()
4460 if (ov->buf_state == BUF_ALLOCATED) in ov51x_alloc()
4463 ov->fbuf = rvmalloc(data_bufsize); in ov51x_alloc()
4464 if (!ov->fbuf) in ov51x_alloc()
4467 ov->rawfbuf = vmalloc(raw_bufsize); in ov51x_alloc()
4468 if (!ov->rawfbuf) in ov51x_alloc()
4471 memset(ov->rawfbuf, 0, raw_bufsize); in ov51x_alloc()
4473 ov->tempfbuf = vmalloc(raw_bufsize); in ov51x_alloc()
4474 if (!ov->tempfbuf) in ov51x_alloc()
4477 memset(ov->tempfbuf, 0, raw_bufsize); in ov51x_alloc()
4480 ov->sbuf[i].data = kmalloc(FRAMES_PER_DESC * in ov51x_alloc()
4482 if (!ov->sbuf[i].data) in ov51x_alloc()
4485 PDEBUG(4, "sbuf[%d] @ %p", i, ov->sbuf[i].data); in ov51x_alloc()
4489 ov->frame[i].data = ov->fbuf + i * MAX_DATA_SIZE(w, h); in ov51x_alloc()
4490 ov->frame[i].rawdata = ov->rawfbuf in ov51x_alloc()
4492 ov->frame[i].tempdata = ov->tempfbuf in ov51x_alloc()
4495 ov->frame[i].compbuf = in ov51x_alloc()
4497 if (!ov->frame[i].compbuf) in ov51x_alloc()
4500 PDEBUG(4, "frame[%d] @ %p", i, ov->frame[i].data); in ov51x_alloc()
4503 ov->buf_state = BUF_ALLOCATED; in ov51x_alloc()
4505 up(&ov->buf_lock); in ov51x_alloc()
4509 ov51x_do_dealloc(ov); in ov51x_alloc()
4510 up(&ov->buf_lock); in ov51x_alloc()
4516 ov51x_dealloc(struct usb_ov511 *ov, int now) in ov51x_dealloc() argument
4519 down(&ov->buf_lock); in ov51x_dealloc()
4520 ov51x_do_dealloc(ov); in ov51x_dealloc()
4521 up(&ov->buf_lock); in ov51x_dealloc()
4535 struct usb_ov511 *ov = vdev->priv; in ov51x_v4l1_open() local
4540 down(&ov->lock); in ov51x_v4l1_open()
4543 if (ov->user) in ov51x_v4l1_open()
4546 err = ov51x_alloc(ov); in ov51x_v4l1_open()
4550 ov->sub_flag = 0; in ov51x_v4l1_open()
4553 err = ov51x_set_default_params(ov); in ov51x_v4l1_open()
4559 ov->frame[i].grabstate = FRAME_UNUSED; in ov51x_v4l1_open()
4560 ov->frame[i].bytes_read = 0; in ov51x_v4l1_open()
4565 if (ov->compress && !ov->decomp_ops) { in ov51x_v4l1_open()
4566 err = request_decompressor(ov); in ov51x_v4l1_open()
4571 err = ov51x_init_isoc(ov); in ov51x_v4l1_open()
4573 ov51x_dealloc(ov, 0); in ov51x_v4l1_open()
4577 ov->user++; in ov51x_v4l1_open()
4580 if (ov->led_policy == LED_AUTO) in ov51x_v4l1_open()
4581 ov51x_led_control(ov, 1); in ov51x_v4l1_open()
4584 up(&ov->lock); in ov51x_v4l1_open()
4592 struct usb_ov511 *ov = vdev->priv; in ov51x_v4l1_close() local
4596 down(&ov->lock); in ov51x_v4l1_close()
4598 ov->user--; in ov51x_v4l1_close()
4599 ov51x_stop_isoc(ov); in ov51x_v4l1_close()
4601 release_decompressor(ov); in ov51x_v4l1_close()
4603 if (ov->led_policy == LED_AUTO) in ov51x_v4l1_close()
4604 ov51x_led_control(ov, 0); in ov51x_v4l1_close()
4606 if (ov->dev) in ov51x_v4l1_close()
4607 ov51x_dealloc(ov, 0); in ov51x_v4l1_close()
4609 up(&ov->lock); in ov51x_v4l1_close()
4613 if (!ov->dev) { in ov51x_v4l1_close()
4614 down(&ov->cbuf_lock); in ov51x_v4l1_close()
4615 kfree(ov->cbuf); in ov51x_v4l1_close()
4616 ov->cbuf = NULL; in ov51x_v4l1_close()
4617 up(&ov->cbuf_lock); in ov51x_v4l1_close()
4619 ov51x_dealloc(ov, 1); in ov51x_v4l1_close()
4620 kfree(ov); in ov51x_v4l1_close()
4621 ov = NULL; in ov51x_v4l1_close()
4634 struct usb_ov511 *ov = vdev->priv; in ov51x_v4l1_ioctl_internal() local
4638 if (!ov->dev) in ov51x_v4l1_ioctl_internal()
4650 symbolic(brglist, ov->bridge)); in ov51x_v4l1_ioctl_internal()
4652 b->channels = ov->num_inputs; in ov51x_v4l1_ioctl_internal()
4654 b->maxwidth = ov->maxwidth; in ov51x_v4l1_ioctl_internal()
4655 b->maxheight = ov->maxheight; in ov51x_v4l1_ioctl_internal()
4656 b->minwidth = ov->minwidth; in ov51x_v4l1_ioctl_internal()
4657 b->minheight = ov->minheight; in ov51x_v4l1_ioctl_internal()
4667 if ((unsigned)(v->channel) >= ov->num_inputs) { in ov51x_v4l1_ioctl_internal()
4672 v->norm = ov->norm; in ov51x_v4l1_ioctl_internal()
4677 decoder_get_input_name(ov, v->channel, v->name); in ov51x_v4l1_ioctl_internal()
4689 if (!ov->has_decoder) { in ov51x_v4l1_ioctl_internal()
4704 if ((unsigned)(v->channel) >= ov->num_inputs) { in ov51x_v4l1_ioctl_internal()
4709 err = decoder_set_input(ov, v->channel); in ov51x_v4l1_ioctl_internal()
4713 err = decoder_set_norm(ov, v->norm); in ov51x_v4l1_ioctl_internal()
4726 if (sensor_get_picture(ov, p)) in ov51x_v4l1_ioctl_internal()
4730 p->depth = ov->frame[0].depth; in ov51x_v4l1_ioctl_internal()
4731 p->palette = ov->frame[0].format; in ov51x_v4l1_ioctl_internal()
4745 if (sensor_set_picture(ov, p)) in ov51x_v4l1_ioctl_internal()
4755 if (p->palette != ov->frame[0].format) { in ov51x_v4l1_ioctl_internal()
4760 interruptible_sleep_on(&ov->wq); in ov51x_v4l1_ioctl_internal()
4763 mode_init_regs(ov, ov->frame[0].width, in ov51x_v4l1_ioctl_internal()
4764 ov->frame[0].height, p->palette, ov->sub_flag); in ov51x_v4l1_ioctl_internal()
4771 ov->frame[i].depth = p->depth; in ov51x_v4l1_ioctl_internal()
4772 ov->frame[i].format = p->palette; in ov51x_v4l1_ioctl_internal()
4783 ov->sub_flag = *vf; in ov51x_v4l1_ioctl_internal()
4809 ov->subx = vc->x; in ov51x_v4l1_ioctl_internal()
4810 ov->suby = vc->y; in ov51x_v4l1_ioctl_internal()
4811 ov->subw = vc->width; in ov51x_v4l1_ioctl_internal()
4812 ov->subh = vc->height; in ov51x_v4l1_ioctl_internal()
4828 if (vw->height != ov->maxheight) in ov51x_v4l1_ioctl_internal()
4830 if (vw->width != ov->maxwidth) in ov51x_v4l1_ioctl_internal()
4836 interruptible_sleep_on(&ov->wq); in ov51x_v4l1_ioctl_internal()
4839 result = mode_init_regs(ov, vw->width, vw->height, in ov51x_v4l1_ioctl_internal()
4840 ov->frame[0].format, ov->sub_flag); in ov51x_v4l1_ioctl_internal()
4845 ov->frame[i].width = vw->width; in ov51x_v4l1_ioctl_internal()
4846 ov->frame[i].height = vw->height; in ov51x_v4l1_ioctl_internal()
4858 vw->width = ov->frame[0].width; in ov51x_v4l1_ioctl_internal()
4859 vw->height = ov->frame[0].height; in ov51x_v4l1_ioctl_internal()
4875 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight); in ov51x_v4l1_ioctl_internal()
4881 + MAX_DATA_SIZE(ov->maxwidth, ov->maxheight); in ov51x_v4l1_ioctl_internal()
4907 if (vm->width > ov->maxwidth in ov51x_v4l1_ioctl_internal()
4908 || vm->height > ov->maxheight) { in ov51x_v4l1_ioctl_internal()
4913 if (ov->frame[f].grabstate == FRAME_GRABBING) { in ov51x_v4l1_ioctl_internal()
4924 if ((ov->frame[f].width != vm->width) || in ov51x_v4l1_ioctl_internal()
4925 (ov->frame[f].height != vm->height) || in ov51x_v4l1_ioctl_internal()
4926 (ov->frame[f].format != vm->format) || in ov51x_v4l1_ioctl_internal()
4927 (ov->frame[f].sub_flag != ov->sub_flag) || in ov51x_v4l1_ioctl_internal()
4928 (ov->frame[f].depth != depth)) { in ov51x_v4l1_ioctl_internal()
4933 interruptible_sleep_on(&ov->wq); in ov51x_v4l1_ioctl_internal()
4935 ret = mode_init_regs(ov, vm->width, vm->height, in ov51x_v4l1_ioctl_internal()
4936 vm->format, ov->sub_flag); in ov51x_v4l1_ioctl_internal()
4943 ov->frame[f].width = vm->width; in ov51x_v4l1_ioctl_internal()
4944 ov->frame[f].height = vm->height; in ov51x_v4l1_ioctl_internal()
4945 ov->frame[f].format = vm->format; in ov51x_v4l1_ioctl_internal()
4946 ov->frame[f].sub_flag = ov->sub_flag; in ov51x_v4l1_ioctl_internal()
4947 ov->frame[f].depth = depth; in ov51x_v4l1_ioctl_internal()
4951 ov->frame[f].grabstate = FRAME_READY; in ov51x_v4l1_ioctl_internal()
4955 return ov51x_new_frame(ov, f); in ov51x_v4l1_ioctl_internal()
4968 frame = &ov->frame[fnum]; in ov51x_v4l1_ioctl_internal()
4980 if (!ov->dev) in ov51x_v4l1_ioctl_internal()
4993 if ((ret = ov51x_new_frame(ov, fnum)) < 0) in ov51x_v4l1_ioctl_internal()
4999 if (ov->snap_enabled && !frame->snapshot) { in ov51x_v4l1_ioctl_internal()
5001 if ((ret = ov51x_new_frame(ov, fnum)) < 0) in ov51x_v4l1_ioctl_internal()
5010 if ((ov->snap_enabled) && (frame->snapshot)) { in ov51x_v4l1_ioctl_internal()
5012 ov51x_clear_snapshot(ov); in ov51x_v4l1_ioctl_internal()
5016 ov51x_postprocess(ov, frame); in ov51x_v4l1_ioctl_internal()
5041 vu->video = ov->vdev.minor; in ov51x_v4l1_ioctl_internal()
5053 return i2c_w_slave(ov, w->slave, w->reg, w->value, w->mask); in ov51x_v4l1_ioctl_internal()
5060 rc = i2c_r_slave(ov, r->slave, r->reg); in ov51x_v4l1_ioctl_internal()
5080 struct usb_ov511 *ov = vdev->priv; in ov51x_v4l1_ioctl() local
5083 if (down_interruptible(&ov->lock)) in ov51x_v4l1_ioctl()
5088 up(&ov->lock); in ov51x_v4l1_ioctl()
5098 struct usb_ov511 *ov = vdev->priv; in ov51x_v4l1_read() local
5102 if (down_interruptible(&ov->lock)) in ov51x_v4l1_read()
5112 if (!ov->dev) { in ov51x_v4l1_read()
5119 if (ov->frame[0].grabstate >= FRAME_DONE) /* _DONE or _ERROR */ in ov51x_v4l1_read()
5121 else if (ov->frame[1].grabstate >= FRAME_DONE)/* _DONE or _ERROR */ in ov51x_v4l1_read()
5133 if (ov->frame[0].grabstate == FRAME_GRABBING) in ov51x_v4l1_read()
5135 else if (ov->frame[1].grabstate == FRAME_GRABBING) in ov51x_v4l1_read()
5141 if ((rc = ov51x_new_frame(ov, frmx = 0))) { in ov51x_v4l1_read()
5147 frame = &ov->frame[frmx]; in ov51x_v4l1_read()
5150 if (!ov->dev) { in ov51x_v4l1_read()
5169 err("** ick! ** Errored frame %d", ov->curframe); in ov51x_v4l1_read()
5170 if (ov51x_new_frame(ov, frmx)) { in ov51x_v4l1_read()
5179 if (ov->snap_enabled) in ov51x_v4l1_read()
5181 if (ov->snap_enabled && !frame->snapshot) { in ov51x_v4l1_read()
5183 if ((rc = ov51x_new_frame(ov, frmx))) { in ov51x_v4l1_read()
5191 if (ov->snap_enabled && frame->snapshot) { in ov51x_v4l1_read()
5193 ov51x_clear_snapshot(ov); in ov51x_v4l1_read()
5197 ov51x_postprocess(ov, frame); in ov51x_v4l1_read()
5229 ov->frame[frmx].grabstate = FRAME_UNUSED; in ov51x_v4l1_read()
5230 if ((rc = ov51x_new_frame(ov, !frmx))) { in ov51x_v4l1_read()
5238 up(&ov->lock); in ov51x_v4l1_read()
5242 up(&ov->lock); in ov51x_v4l1_read()
5252 struct usb_ov511 *ov = vdev->priv; in ov51x_v4l1_mmap() local
5255 if (ov->dev == NULL) in ov51x_v4l1_mmap()
5261 * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight) in ov51x_v4l1_mmap()
5265 if (down_interruptible(&ov->lock)) in ov51x_v4l1_mmap()
5268 pos = (unsigned long)ov->fbuf; in ov51x_v4l1_mmap()
5272 up(&ov->lock); in ov51x_v4l1_mmap()
5283 up(&ov->lock); in ov51x_v4l1_mmap()
5311 struct usb_ov511 *ov; in ov51x_control_ioctl() local
5318 ov = pde->data; in ov51x_control_ioctl()
5319 if (!ov) in ov51x_control_ioctl()
5322 if (!ov->dev) in ov51x_control_ioctl()
5347 rc = sensor_get_brightness(ov, &(opt.val)); in ov51x_control_ioctl()
5351 rc = sensor_get_saturation(ov, &(opt.val)); in ov51x_control_ioctl()
5355 rc = sensor_get_hue(ov, &(opt.val)); in ov51x_control_ioctl()
5359 rc = sensor_get_contrast(ov, &(opt.val)); in ov51x_control_ioctl()
5381 rc = sensor_set_brightness(ov, opt.val); in ov51x_control_ioctl()
5385 rc = sensor_set_saturation(ov, opt.val); in ov51x_control_ioctl()
5389 rc = sensor_set_hue(ov, opt.val); in ov51x_control_ioctl()
5393 rc = sensor_set_contrast(ov, opt.val); in ov51x_control_ioctl()
5412 opt.val = ov->lightfreq; in ov51x_control_ioctl()
5415 opt.val = ov->bandfilt; in ov51x_control_ioctl()
5418 opt.val = ov->led_policy; in ov51x_control_ioctl()
5424 opt.val = ov->compress; in ov51x_control_ioctl()
5445 rc = sensor_set_light_freq(ov, opt.val); in ov51x_control_ioctl()
5449 rc = sensor_set_banding_filter(ov, opt.val); in ov51x_control_ioctl()
5454 ov->led_policy = opt.val; in ov51x_control_ioctl()
5455 if (ov->led_policy == LED_OFF) in ov51x_control_ioctl()
5456 ov51x_led_control(ov, 0); in ov51x_control_ioctl()
5457 else if (ov->led_policy == LED_ON) in ov51x_control_ioctl()
5458 ov51x_led_control(ov, 1); in ov51x_control_ioctl()
5470 ov->compress = opt.val; in ov51x_control_ioctl()
5471 if (ov->compress) { in ov51x_control_ioctl()
5472 if (ov->bclass == BCL_OV511) in ov51x_control_ioctl()
5473 ov511_init_compression(ov); in ov51x_control_ioctl()
5474 else if (ov->bclass == BCL_OV518) in ov51x_control_ioctl()
5475 ov518_init_compression(ov); in ov51x_control_ioctl()
5492 return i2c_w_slave(ov, w.slave, w.reg, w.value, w.mask); in ov51x_control_ioctl()
5501 rc = i2c_r_slave(ov, r.slave, r.reg); in ov51x_control_ioctl()
5530 ov7xx0_configure(struct usb_ov511 *ov) in ov7xx0_configure() argument
5647 ov->primary_i2c_slave = OV7xx0_SID; in ov7xx0_configure()
5648 if (ov51x_set_slave_ids(ov, OV7xx0_SID) < 0) in ov7xx0_configure()
5651 if (init_ov_sensor(ov) >= 0) { in ov7xx0_configure()
5655 if (i2c_w(ov, 0x12, 0x80) < 0) return -1; in ov7xx0_configure()
5663 if ((i2c_r(ov, OV7610_REG_ID_HIGH) == 0x7F) && in ov7xx0_configure()
5664 (i2c_r(ov, OV7610_REG_ID_LOW) == 0xA2)) { in ov7xx0_configure()
5688 rc = i2c_r(ov, OV7610_REG_COM_I); in ov7xx0_configure()
5695 ov->sensor = SEN_OV7610; in ov7xx0_configure()
5698 if (i2c_r(ov, 0x15) & 1) in ov7xx0_configure()
5706 if (ov->bridge == BRG_OV511PLUS) { in ov7xx0_configure()
5708 ov->sensor = SEN_OV7620; in ov7xx0_configure()
5710 ov->sensor = SEN_OV76BE; in ov7xx0_configure()
5714 ov->sensor = SEN_OV7620; in ov7xx0_configure()
5720 if (ov->sensor == SEN_OV7620) { in ov7xx0_configure()
5722 if (write_regvals(ov, aRegvalsNorm7620)) in ov7xx0_configure()
5726 if (write_regvals(ov, aRegvalsNorm7610)) in ov7xx0_configure()
5731 ov->maxwidth = 640; in ov7xx0_configure()
5732 ov->maxheight = 480; in ov7xx0_configure()
5733 ov->minwidth = 64; in ov7xx0_configure()
5734 ov->minheight = 48; in ov7xx0_configure()
5737 ov->brightness = 0x80 << 8; in ov7xx0_configure()
5738 ov->contrast = 0x80 << 8; in ov7xx0_configure()
5739 ov->colour = 0x80 << 8; in ov7xx0_configure()
5740 ov->hue = 0x80 << 8; in ov7xx0_configure()
5747 ov6xx0_configure(struct usb_ov511 *ov) in ov6xx0_configure() argument
5851 if (init_ov_sensor(ov) < 0) { in ov6xx0_configure()
5860 rc = i2c_r(ov, OV7610_REG_COM_I); in ov6xx0_configure()
5868 ov->sensor = SEN_OV6630; in ov6xx0_configure()
5871 ov->sensor = SEN_OV6620; in ov6xx0_configure()
5874 ov->sensor = SEN_OV6630; in ov6xx0_configure()
5877 ov->sensor = SEN_OV6630; in ov6xx0_configure()
5882 ov->maxwidth = 352; in ov6xx0_configure()
5883 ov->maxheight = 288; in ov6xx0_configure()
5884 ov->minwidth = 64; in ov6xx0_configure()
5885 ov->minheight = 48; in ov6xx0_configure()
5888 ov->brightness = 0x80 << 8; in ov6xx0_configure()
5889 ov->contrast = 0x80 << 8; in ov6xx0_configure()
5890 ov->colour = 0x80 << 8; in ov6xx0_configure()
5891 ov->hue = 0x80 << 8; in ov6xx0_configure()
5893 if (ov->sensor == SEN_OV6620) { in ov6xx0_configure()
5895 if (write_regvals(ov, aRegvalsNorm6x20)) in ov6xx0_configure()
5899 if (write_regvals(ov, aRegvalsNorm6x30)) in ov6xx0_configure()
5908 ks0127_configure(struct usb_ov511 *ov) in ks0127_configure() argument
5914 if (ov51x_init_ks_sensor(ov) < 0) { in ks0127_configure()
5923 rc = i2c_r(ov, 0x00); in ks0127_configure()
5928 rc = i2c_r(ov, 0x3d); in ks0127_configure()
5934 ov->sensor = SEN_KS0127; in ks0127_configure()
5937 ov->sensor = SEN_KS0127B; in ks0127_configure()
5945 ov->maxwidth = 640; in ks0127_configure()
5946 ov->maxheight = 480; in ks0127_configure()
5947 ov->minwidth = 64; in ks0127_configure()
5948 ov->minheight = 48; in ks0127_configure()
5951 ov->brightness = 0x80 << 8; in ks0127_configure()
5952 ov->contrast = 0x80 << 8; in ks0127_configure()
5953 ov->colour = 0x80 << 8; in ks0127_configure()
5954 ov->hue = 0x80 << 8; in ks0127_configure()
5965 saa7111a_configure(struct usb_ov511 *ov) in saa7111a_configure() argument
6001 if (ov51x_init_saa_sensor(ov) < 0) { in saa7111a_configure()
6010 if (ov->pal) { in saa7111a_configure()
6011 ov->maxwidth = 320; in saa7111a_configure()
6012 ov->maxheight = 240; /* Even field only */ in saa7111a_configure()
6014 ov->maxwidth = 640; in saa7111a_configure()
6015 ov->maxheight = 480; /* Even/Odd fields */ in saa7111a_configure()
6018 ov->minwidth = 320; in saa7111a_configure()
6019 ov->minheight = 240; /* Even field only */ in saa7111a_configure()
6021 ov->has_decoder = 1; in saa7111a_configure()
6022 ov->num_inputs = 8; in saa7111a_configure()
6023 ov->norm = VIDEO_MODE_AUTO; in saa7111a_configure()
6024 ov->stop_during_set = 0; /* Decoder guarantees stable image */ in saa7111a_configure()
6028 ov->brightness = 0x80 << 8; in saa7111a_configure()
6029 ov->contrast = 0x40 << 9; in saa7111a_configure()
6030 ov->colour = 0x40 << 9; in saa7111a_configure()
6031 ov->hue = 32768; in saa7111a_configure()
6034 if (write_regvals(ov, aRegvalsNormSAA7111A)) in saa7111a_configure()
6039 rc = i2c_r(ov, 0x00); in saa7111a_configure()
6046 ov->sensor = SEN_SAA7111A; in saa7111a_configure()
6052 if (ov->bclass == BCL_OV511) in saa7111a_configure()
6053 reg_w(ov, 0x11, 0x00); in saa7111a_configure()
6062 ov511_configure(struct usb_ov511 *ov) in ov511_configure() argument
6099 ov->customid = reg_r(ov, R511_SYS_CUST_ID); in ov511_configure()
6100 if (ov->customid < 0) { in ov511_configure()
6105 PDEBUG (1, "CustomID = %d", ov->customid); in ov511_configure()
6106 ov->desc = symbolic(camlist, ov->customid); in ov511_configure()
6107 info("model: %s", ov->desc); in ov511_configure()
6109 if (0 == strcmp(ov->desc, NOT_DEFINED_STR)) { in ov511_configure()
6110 err("Camera type (%d) not recognized", ov->customid); in ov511_configure()
6116 if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */ in ov511_configure()
6117 ov->pal = 1; in ov511_configure()
6119 if (write_regvals(ov, aRegvalsInit511)) goto error; in ov511_configure()
6121 if (ov->led_policy == LED_OFF || ov->led_policy == LED_AUTO) in ov511_configure()
6122 ov51x_led_control(ov, 0); in ov511_configure()
6126 if (ov->bridge == BRG_OV511) { in ov511_configure()
6127 if (write_regvals(ov, aRegvalsNorm511)) goto error; in ov511_configure()
6128 } else if (ov->bridge == BRG_OV511PLUS) { in ov511_configure()
6129 if (write_regvals(ov, aRegvalsNorm511Plus)) goto error; in ov511_configure()
6134 if (ov511_init_compression(ov)) goto error; in ov511_configure()
6136 ov->packet_numbering = 1; in ov511_configure()
6137 ov511_set_packet_size(ov, 0); in ov511_configure()
6139 ov->snap_enabled = snapshot; in ov511_configure()
6143 ov->primary_i2c_slave = OV7xx0_SID; in ov511_configure()
6144 if (ov51x_set_slave_ids(ov, OV7xx0_SID) < 0) in ov511_configure()
6147 if (i2c_w(ov, 0x12, 0x80) < 0) { in ov511_configure()
6150 ov->primary_i2c_slave = OV6xx0_SID; in ov511_configure()
6151 if (ov51x_set_slave_ids(ov, OV6xx0_SID) < 0) in ov511_configure()
6154 if (i2c_w(ov, 0x12, 0x80) < 0) { in ov511_configure()
6157 ov->primary_i2c_slave = OV8xx0_SID; in ov511_configure()
6158 if (ov51x_set_slave_ids(ov, OV8xx0_SID) < 0) in ov511_configure()
6161 if (i2c_w(ov, 0x12, 0x80) < 0) { in ov511_configure()
6164 ov->primary_i2c_slave = SAA7111A_SID; in ov511_configure()
6165 if (ov51x_set_slave_ids(ov, SAA7111A_SID) < 0) in ov511_configure()
6168 if (i2c_w(ov, 0x0d, 0x00) < 0) { in ov511_configure()
6171 ov->primary_i2c_slave = KS0127_SID; in ov511_configure()
6172 if (ov51x_set_slave_ids(ov, KS0127_SID) < 0) in ov511_configure()
6175 if (i2c_w(ov, 0x10, 0x00) < 0) { in ov511_configure()
6179 if (ks0127_configure(ov) < 0) { in ov511_configure()
6185 if (saa7111a_configure(ov) < 0) { in ov511_configure()
6195 if (ov6xx0_configure(ov) < 0) { in ov511_configure()
6201 if (ov7xx0_configure(ov) < 0) { in ov511_configure()
6217 ov518_configure(struct usb_ov511 *ov) in ov518_configure() argument
6267 info("Device revision %d", 0x1F & reg_r(ov, R511_SYS_CUST_ID)); in ov518_configure()
6270 ov->desc = symbolic(camlist, 0); in ov518_configure()
6272 if (write_regvals(ov, aRegvalsInit518)) goto error; in ov518_configure()
6275 if (reg_w_mask(ov, 0x57, 0x00, 0x02) < 0) goto error; in ov518_configure()
6278 if (ov->led_policy == LED_OFF || ov->led_policy == LED_AUTO) in ov518_configure()
6279 ov51x_led_control(ov, 0); in ov518_configure()
6281 ov51x_led_control(ov, 1); in ov518_configure()
6285 if (!dumppix && !ov->compress) { in ov518_configure()
6286 ov->compress = 1; in ov518_configure()
6290 if (ov->bridge == BRG_OV518) { in ov518_configure()
6291 if (write_regvals(ov, aRegvalsNorm518)) goto error; in ov518_configure()
6292 } else if (ov->bridge == BRG_OV518PLUS) { in ov518_configure()
6293 if (write_regvals(ov, aRegvalsNorm518Plus)) goto error; in ov518_configure()
6298 if (reg_w(ov, 0x2f, 0x80) < 0) goto error; in ov518_configure()
6300 if (ov518_init_compression(ov)) goto error; in ov518_configure()
6302 if (ov->bridge == BRG_OV518) in ov518_configure()
6304 struct usb_interface *ifp = &ov->dev->config[0].interface[0]; in ov518_configure()
6309 ov->packet_numbering = 1; in ov518_configure()
6311 ov->packet_numbering = 0; in ov518_configure()
6314 ov->packet_numbering = 1; in ov518_configure()
6317 ov518_set_packet_size(ov, 0); in ov518_configure()
6319 ov->snap_enabled = snapshot; in ov518_configure()
6322 ov->primary_i2c_slave = OV7xx0_SID; in ov518_configure()
6323 if (ov51x_set_slave_ids(ov, OV7xx0_SID) < 0) in ov518_configure()
6330 if (init_ov_sensor(ov) < 0) { in ov518_configure()
6332 ov->primary_i2c_slave = OV6xx0_SID; in ov518_configure()
6333 if (ov51x_set_slave_ids(ov, OV6xx0_SID) < 0) in ov518_configure()
6336 if (init_ov_sensor(ov) < 0) { in ov518_configure()
6338 ov->primary_i2c_slave = OV8xx0_SID; in ov518_configure()
6339 if (ov51x_set_slave_ids(ov, OV8xx0_SID) < 0) in ov518_configure()
6342 if (init_ov_sensor(ov) < 0) { in ov518_configure()
6350 if (ov6xx0_configure(ov) < 0) { in ov518_configure()
6356 if (ov7xx0_configure(ov) < 0) { in ov518_configure()
6362 ov->maxwidth = 352; in ov518_configure()
6363 ov->maxheight = 288; in ov518_configure()
6366 ov->minwidth = 160; in ov518_configure()
6367 ov->minheight = 120; in ov518_configure()
6389 struct usb_ov511 *ov; in ov51x_probe() local
6410 if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) { in ov51x_probe()
6415 memset(ov, 0, sizeof(*ov)); in ov51x_probe()
6417 ov->dev = dev; in ov51x_probe()
6418 ov->iface = interface->bInterfaceNumber; in ov51x_probe()
6419 ov->led_policy = led; in ov51x_probe()
6420 ov->compress = compress; in ov51x_probe()
6421 ov->lightfreq = lightfreq; in ov51x_probe()
6422 ov->num_inputs = 1; /* Video decoder init functs. change this */ in ov51x_probe()
6423 ov->stop_during_set = !fastset; in ov51x_probe()
6424 ov->backlight = backlight; in ov51x_probe()
6425 ov->mirror = mirror; in ov51x_probe()
6426 ov->auto_brt = autobright; in ov51x_probe()
6427 ov->auto_gain = autogain; in ov51x_probe()
6428 ov->auto_exp = autoexp; in ov51x_probe()
6432 ov->bridge = BRG_OV511; in ov51x_probe()
6433 ov->bclass = BCL_OV511; in ov51x_probe()
6436 ov->bridge = BRG_OV511PLUS; in ov51x_probe()
6437 ov->bclass = BCL_OV511; in ov51x_probe()
6440 ov->bridge = BRG_OV518; in ov51x_probe()
6441 ov->bclass = BCL_OV518; in ov51x_probe()
6444 ov->bridge = BRG_OV518PLUS; in ov51x_probe()
6445 ov->bclass = BCL_OV518; in ov51x_probe()
6450 ov->bridge = BRG_OV511PLUS; in ov51x_probe()
6451 ov->bclass = BCL_OV511; in ov51x_probe()
6458 info("USB %s video device found", symbolic(brglist, ov->bridge)); in ov51x_probe()
6465 init_waitqueue_head(&ov->wq); in ov51x_probe()
6467 init_MUTEX(&ov->lock); /* to 1 == available */ in ov51x_probe()
6468 init_MUTEX(&ov->buf_lock); in ov51x_probe()
6469 init_MUTEX(&ov->param_lock); in ov51x_probe()
6470 init_MUTEX(&ov->i2c_lock); in ov51x_probe()
6471 init_MUTEX(&ov->cbuf_lock); in ov51x_probe()
6473 ov->buf_state = BUF_NOT_ALLOCATED; in ov51x_probe()
6475 if (usb_make_path(dev, ov->usb_path, OV511_USB_PATH_LEN) < 0) { in ov51x_probe()
6482 ov->cbuf = kmalloc(OV511_CBUF_SIZE, GFP_KERNEL); in ov51x_probe()
6483 if (!ov->cbuf) in ov51x_probe()
6486 if (ov->bclass == BCL_OV518) { in ov51x_probe()
6487 if (ov518_configure(ov) < 0) in ov51x_probe()
6490 if (ov511_configure(ov) < 0) in ov51x_probe()
6495 ov->frame[i].framenum = i; in ov51x_probe()
6496 init_waitqueue_head(&ov->frame[i].wq); in ov51x_probe()
6500 ov->sbuf[i].ov = ov; in ov51x_probe()
6501 spin_lock_init(&ov->sbuf[i].lock); in ov51x_probe()
6502 ov->sbuf[i].n = i; in ov51x_probe()
6507 if (ov51x_set_default_params(ov) < 0) in ov51x_probe()
6512 if (ov->bclass == BCL_OV511) in ov51x_probe()
6513 ov511_dump_regs(ov); in ov51x_probe()
6515 ov518_dump_regs(ov); in ov51x_probe()
6519 memcpy(&ov->vdev, &vdev_template, sizeof(vdev_template)); in ov51x_probe()
6520 ov->vdev.priv = ov; in ov51x_probe()
6527 if (video_register_device(&ov->vdev, VFL_TYPE_GRABBER, in ov51x_probe()
6536 video_register_device(&ov->vdev, VFL_TYPE_GRABBER, -1) < 0) { in ov51x_probe()
6541 info("Device at %s registered to minor %d", ov->usb_path, in ov51x_probe()
6542 ov->vdev.minor); in ov51x_probe()
6545 create_proc_ov511_cam(ov); in ov51x_probe()
6549 return ov; in ov51x_probe()
6554 destroy_proc_ov511_cam(ov); in ov51x_probe()
6557 if (ov->cbuf) { in ov51x_probe()
6558 down(&ov->cbuf_lock); in ov51x_probe()
6559 kfree(ov->cbuf); in ov51x_probe()
6560 ov->cbuf = NULL; in ov51x_probe()
6561 up(&ov->cbuf_lock); in ov51x_probe()
6565 if (ov) { in ov51x_probe()
6566 kfree(ov); in ov51x_probe()
6567 ov = NULL; in ov51x_probe()
6580 struct usb_ov511 *ov = (struct usb_ov511 *) ptr; in ov51x_disconnect() local
6587 video_unregister_device(&ov->vdev); in ov51x_disconnect()
6588 if (ov->user) in ov51x_disconnect()
6592 ov->frame[n].grabstate = FRAME_ERROR; in ov51x_disconnect()
6594 ov->curframe = -1; in ov51x_disconnect()
6598 if (waitqueue_active(&ov->frame[n].wq)) in ov51x_disconnect()
6599 wake_up_interruptible(&ov->frame[n].wq); in ov51x_disconnect()
6600 if (waitqueue_active(&ov->wq)) in ov51x_disconnect()
6601 wake_up_interruptible(&ov->wq); in ov51x_disconnect()
6603 ov->streaming = 0; in ov51x_disconnect()
6605 ov51x_unlink_isoc(ov); in ov51x_disconnect()
6608 destroy_proc_ov511_cam(ov); in ov51x_disconnect()
6611 ov->dev = NULL; in ov51x_disconnect()
6614 if (ov && !ov->user) { in ov51x_disconnect()
6615 down(&ov->cbuf_lock); in ov51x_disconnect()
6616 kfree(ov->cbuf); in ov51x_disconnect()
6617 ov->cbuf = NULL; in ov51x_disconnect()
6618 up(&ov->cbuf_lock); in ov51x_disconnect()
6620 ov51x_dealloc(ov, 1); in ov51x_disconnect()
6621 kfree(ov); in ov51x_disconnect()
6622 ov = NULL; in ov51x_disconnect()