Lines Matching +full:adc +full:- +full:alt +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2008-2011 Jean-François Moine <moinejf@free.fr>
8 * This module is adapted from the ov51x-jpeg package, which itself
13 * Copyright (c) 1999-2006 Mark W. McClelland
20 * ov51x-jpeg original copyright is:
22 * Copyright (c) 2004-2007 Romain Beauxis <toots@rastageeks.org>
38 MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
482 /*jfm: this value does not work for 800x600 - see isoc_init */
502 #define OV7610_REG_BLUE 0x01 /* blue channel balance */
503 #define OV7610_REG_RED 0x02 /* red channel balance */
539 #define OV7670_R14_COM9 0x14 /* Control 9 - gain ceiling */
605 /* ms-win traces */
697 * COME[6] "Anti-blooming control"
702 * = 0 (0x00) .....0.. "Tri-state data output pin
705 * = 0 (0x00) ......0. "Tri-state VSYNC, PCLK,
738 * COMG[3] "Channel offset adjustment"
740 * COMG[2] "ADC black level calibration option"
743 * channel's black level"
746 * COMG[0] "ADC black level calibration enable"
814 * CHLF[1] "ADC current control"
844 * 37 ADC "ADC Reference Control"
846 * ADC[7:4] "Reserved"
848 * ADC[3] "ADC input signal range"
850 * ADC[2:0] "ADC range control"
1002 * CHLF[1] "ADC current control"
1042 * CHLF[1] "ADC current control"
1063 * = 0 (0x00) 0....... "No-op"
1068 * COMH[2] "Internal B/R channel option"
1069 * = 0 (0x00) .....0.. "B/R use same channel"
1150 * = 0 (0x00) 0....... "No-op"
1155 * COMH[2] "Internal B/R channel option"
1156 * = 0 (0x00) .....0.. "B/R use same channel"
1168 * = 0 (0x00) 0....... "No-op"
1173 * COMH[2] "Internal B/R channel option"
1174 * = 0 (0x00) .....0.. "B/R use same channel"
1334 /* Do 50-53 have any effect? */
1377 { 0x2d, 0x95 }, /* Enable auto-brightness */
1541 { 0xa2, 0x20 }, /* a2-a5 are undocumented */
1548 { 0x20, 0x0c }, /* 0x0d does U <-> V swap */
1588 {0x37, 0x04}, /* ADC */
1706 * make sense - hstop is less than hstart. But they work...
1867 /* Extra-weird stuff. Some sort of multiplexor register */
1955 { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */
1985 return (128 - v) | 0x80; in ov7670_abs_to_sm()
1994 if (sd->gspca_dev.usb_err < 0) in reg_w()
2000 switch (sd->bridge) { in reg_w()
2011 ret = usb_control_msg(sd->gspca_dev.dev, in reg_w()
2012 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in reg_w()
2023 sd->gspca_dev.usb_buf[0] = value; in reg_w()
2024 ret = usb_control_msg(sd->gspca_dev.dev, in reg_w()
2025 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in reg_w()
2029 sd->gspca_dev.usb_buf, 1, 500); in reg_w()
2033 sd->gspca_dev.usb_err = ret; in reg_w()
2046 if (sd->gspca_dev.usb_err < 0) in reg_r()
2047 return -1; in reg_r()
2049 switch (sd->bridge) { in reg_r()
2063 ret = usb_control_msg(sd->gspca_dev.dev, in reg_r()
2064 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), in reg_r()
2067 0, index, sd->gspca_dev.usb_buf, 1, 500); in reg_r()
2070 ret = sd->gspca_dev.usb_buf[0]; in reg_r()
2075 sd->gspca_dev.usb_err = ret; in reg_r()
2080 gspca_dev->usb_buf[0] = 0; in reg_r()
2093 if (sd->gspca_dev.usb_err < 0) in reg_r8()
2094 return -1; in reg_r8()
2098 ret = usb_control_msg(sd->gspca_dev.dev, in reg_r8()
2099 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), in reg_r8()
2102 0, index, sd->gspca_dev.usb_buf, 8, 500); in reg_r8()
2105 ret = sd->gspca_dev.usb_buf[0]; in reg_r8()
2108 sd->gspca_dev.usb_err = ret; in reg_r8()
2113 memset(gspca_dev->usb_buf, 0, 8); in reg_r8()
2147 * registers (0x30 and 0xc4 - 0xce).
2154 if (sd->gspca_dev.usb_err < 0) in ov518_reg_w32()
2157 *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); in ov518_reg_w32()
2161 ret = usb_control_msg(sd->gspca_dev.dev, in ov518_reg_w32()
2162 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in ov518_reg_w32()
2166 sd->gspca_dev.usb_buf, n, 500); in ov518_reg_w32()
2169 sd->gspca_dev.usb_err = ret; in ov518_reg_w32()
2188 /* Initiate 3-byte write cycle */ in ov511_i2c_w()
2200 if (--retries < 0) { in ov511_i2c_w()
2217 /* Initiate 2-byte write cycle */ in ov511_i2c_r()
2233 if (--retries < 0) { in ov511_i2c_r()
2235 return -1; in ov511_i2c_r()
2241 /* Initiate 2-byte read cycle */ in ov511_i2c_r()
2257 if (--retries < 0) { in ov511_i2c_r()
2259 return -1; in ov511_i2c_r()
2292 /* Initiate 3-byte write cycle */ in ov518_i2c_w()
2315 /* Initiate 2-byte write cycle */ in ov518_i2c_r()
2319 /* Initiate 2-byte read cycle */ in ov518_i2c_r()
2333 if (sd->gspca_dev.usb_err < 0) in ovfx2_i2c_w()
2336 ret = usb_control_msg(sd->gspca_dev.dev, in ovfx2_i2c_w()
2337 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in ovfx2_i2c_w()
2344 sd->gspca_dev.usb_err = ret; in ovfx2_i2c_w()
2355 if (sd->gspca_dev.usb_err < 0) in ovfx2_i2c_r()
2356 return -1; in ovfx2_i2c_r()
2358 ret = usb_control_msg(sd->gspca_dev.dev, in ovfx2_i2c_r()
2359 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), in ovfx2_i2c_r()
2362 0, (u16) reg, sd->gspca_dev.usb_buf, 1, 500); in ovfx2_i2c_r()
2365 ret = sd->gspca_dev.usb_buf[0]; in ovfx2_i2c_r()
2370 sd->gspca_dev.usb_err = ret; in ovfx2_i2c_r()
2378 if (sd->sensor_reg_cache[reg] == value) in i2c_w()
2381 switch (sd->bridge) { in i2c_w()
2399 if (sd->gspca_dev.usb_err >= 0) { in i2c_w()
2402 memset(sd->sensor_reg_cache, -1, in i2c_w()
2403 sizeof(sd->sensor_reg_cache)); in i2c_w()
2405 sd->sensor_reg_cache[reg] = value; in i2c_w()
2411 int ret = -1; in i2c_r()
2413 if (sd->sensor_reg_cache[reg] != -1) in i2c_r()
2414 return sd->sensor_reg_cache[reg]; in i2c_r()
2416 switch (sd->bridge) { in i2c_r()
2435 sd->sensor_reg_cache[reg] = ret; in i2c_r()
2469 sd->stopped = 1; in ov51x_stop()
2470 switch (sd->bridge) { in ov51x_stop()
2500 if (!sd->stopped) in ov51x_restart()
2502 sd->stopped = 0; in ov51x_restart()
2505 switch (sd->bridge) { in ov51x_restart()
2563 return -1; in init_ov_sensor()
2565 return -1; in init_ov_sensor()
2576 switch (sd->bridge) { in ov51x_set_slave_ids()
2581 sd->sensor_addr = slave; in ov51x_set_slave_ids()
2593 while (--n >= 0) { in write_regvals()
2594 reg_w(sd, regvals->reg, regvals->val); in write_regvals()
2603 while (--n >= 0) { in write_i2c_regvals()
2604 i2c_w(sd, regvals->reg, regvals->val); in write_i2c_regvals()
2621 if (sd->bridge != BRIDGE_OVFX2) { in ov_hires_configure()
2637 sd->sensor = SEN_OV2610; in ov_hires_configure()
2641 sd->sensor = SEN_OV2610AE; in ov_hires_configure()
2645 sd->sensor = SEN_OV9600; in ov_hires_configure()
2652 sd->sensor = SEN_OV3610; in ov_hires_configure()
2678 sd->sensor = SEN_OV8610; in ov8xx0_configure()
2711 sd->sensor = SEN_OV7670; in ov7xx0_configure()
2714 sd->sensor = SEN_OV7610; in ov7xx0_configure()
2720 sd->sensor = SEN_OV7620AE; in ov7xx0_configure()
2723 sd->sensor = SEN_OV76BE; in ov7xx0_configure()
2745 sd->sensor = SEN_OV7640; /* FIXME */ in ov7xx0_configure()
2749 sd->sensor = SEN_OV7640; /* FIXME */ in ov7xx0_configure()
2753 sd->sensor = SEN_OV7648; in ov7xx0_configure()
2757 sd->sensor = SEN_OV7660; in ov7xx0_configure()
2766 sd->sensor = SEN_OV7620; in ov7xx0_configure()
2794 sd->sensor = SEN_OV6630; in ov6xx0_configure()
2798 sd->sensor = SEN_OV6620; in ov6xx0_configure()
2802 sd->sensor = SEN_OV6630; in ov6xx0_configure()
2806 sd->sensor = SEN_OV66308AF; in ov6xx0_configure()
2810 sd->sensor = SEN_OV6630; in ov6xx0_configure()
2819 /* Set sensor-specific vars */ in ov6xx0_configure()
2820 sd->sif = 1; in ov6xx0_configure()
2826 if (sd->invert_led) in ov51x_led_control()
2829 switch (sd->bridge) { in ov51x_led_control()
2848 if (!sd->snapshot_needs_reset) in sd_reset_snapshot()
2851 /* Note it is important that we clear sd->snapshot_needs_reset, in sd_reset_snapshot()
2854 sd->snapshot_needs_reset = 0; in sd_reset_snapshot()
2856 switch (sd->bridge) { in sd_reset_snapshot()
2919 if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) { in ov51x_upload_quan_tables()
3000 switch (sd->bridge) { in ov511_configure()
3065 sd->revision = reg_r(sd, R51x_SYS_CUST_ID) & 0x1f; in ov518_configure()
3066 gspca_dbg(gspca_dev, D_PROBE, "Device revision %d\n", sd->revision); in ov518_configure()
3073 switch (sd->bridge) { in ov518_configure()
3120 sd->stopped = 1; in ovfx2_configure()
3154 write_regvals(sd, bridge_ov7660[sd->gspca_dev.curr_mode], in ov519_set_mode()
3156 write_i2c_regvals(sd, sensor_ov7660[sd->gspca_dev.curr_mode], in ov519_set_mode()
3169 * - mode = 0: 320x240, 1: 640x480 in ov519_set_fr()
3170 * - fr rate = 0: 30, 1: 25, 2: 20, 3: 15, 4: 10, 5: 5 in ov519_set_fr()
3171 * - reg = 0: bridge a4, 1: bridge 23, 2: sensor 11 (clock) in ov519_set_fr()
3189 sd->frame_rate = frame_rate; in ov519_set_fr()
3190 if (sd->frame_rate >= 30) in ov519_set_fr()
3192 else if (sd->frame_rate >= 25) in ov519_set_fr()
3194 else if (sd->frame_rate >= 20) in ov519_set_fr()
3196 else if (sd->frame_rate >= 15) in ov519_set_fr()
3198 else if (sd->frame_rate >= 10) in ov519_set_fr()
3202 reg_w(sd, 0xa4, fr_tb[sd->gspca_dev.curr_mode][fr][0]); in ov519_set_fr()
3203 reg_w(sd, 0x23, fr_tb[sd->gspca_dev.curr_mode][fr][1]); in ov519_set_fr()
3204 clock = fr_tb[sd->gspca_dev.curr_mode][fr][2]; in ov519_set_fr()
3205 if (sd->sensor == SEN_OV7660) in ov519_set_fr()
3222 struct cam *cam = &gspca_dev->cam; in sd_config()
3224 sd->bridge = id->driver_info & BRIDGE_MASK; in sd_config()
3225 sd->invert_led = (id->driver_info & BRIDGE_INVERT_LED) != 0; in sd_config()
3227 switch (sd->bridge) { in sd_config()
3230 cam->cam_mode = ov511_vga_mode; in sd_config()
3231 cam->nmodes = ARRAY_SIZE(ov511_vga_mode); in sd_config()
3235 cam->cam_mode = ov518_vga_mode; in sd_config()
3236 cam->nmodes = ARRAY_SIZE(ov518_vga_mode); in sd_config()
3239 cam->cam_mode = ov519_vga_mode; in sd_config()
3240 cam->nmodes = ARRAY_SIZE(ov519_vga_mode); in sd_config()
3243 cam->cam_mode = ov519_vga_mode; in sd_config()
3244 cam->nmodes = ARRAY_SIZE(ov519_vga_mode); in sd_config()
3245 cam->bulk_size = OVFX2_BULK_SIZE; in sd_config()
3246 cam->bulk_nurbs = MAX_NURBS; in sd_config()
3247 cam->bulk = 1; in sd_config()
3250 cam->cam_mode = w9968cf_vga_mode; in sd_config()
3251 cam->nmodes = ARRAY_SIZE(w9968cf_vga_mode); in sd_config()
3255 sd->frame_rate = 15; in sd_config()
3264 struct cam *cam = &gspca_dev->cam; in sd_init()
3266 switch (sd->bridge) { in sd_init()
3289 sd->sensor = -1; in sd_init()
3311 if (sd->sensor < 0) in sd_init()
3316 switch (sd->bridge) { in sd_init()
3319 if (sd->sif) { in sd_init()
3320 cam->cam_mode = ov511_sif_mode; in sd_init()
3321 cam->nmodes = ARRAY_SIZE(ov511_sif_mode); in sd_init()
3326 if (sd->sif) { in sd_init()
3327 cam->cam_mode = ov518_sif_mode; in sd_init()
3328 cam->nmodes = ARRAY_SIZE(ov518_sif_mode); in sd_init()
3332 if (sd->sif) { in sd_init()
3333 cam->cam_mode = ov519_sif_mode; in sd_init()
3334 cam->nmodes = ARRAY_SIZE(ov519_sif_mode); in sd_init()
3338 switch (sd->sensor) { in sd_init()
3341 cam->cam_mode = ovfx2_ov2610_mode; in sd_init()
3342 cam->nmodes = ARRAY_SIZE(ovfx2_ov2610_mode); in sd_init()
3345 cam->cam_mode = ovfx2_ov3610_mode; in sd_init()
3346 cam->nmodes = ARRAY_SIZE(ovfx2_ov3610_mode); in sd_init()
3349 cam->cam_mode = ovfx2_ov9600_mode; in sd_init()
3350 cam->nmodes = ARRAY_SIZE(ovfx2_ov9600_mode); in sd_init()
3353 if (sd->sif) { in sd_init()
3354 cam->cam_mode = ov519_sif_mode; in sd_init()
3355 cam->nmodes = ARRAY_SIZE(ov519_sif_mode); in sd_init()
3361 if (sd->sif) in sd_init()
3362 cam->nmodes = ARRAY_SIZE(w9968cf_vga_mode) - 1; in sd_init()
3370 switch (sd->sensor) { in sd_init()
3417 sd->gspca_dev.curr_mode = 1; /* 640x480 */ in sd_init()
3438 return gspca_dev->usb_err; in sd_init()
3441 return -EINVAL; in sd_init()
3449 switch (sd->bridge) { in sd_isoc_init()
3451 if (gspca_dev->pixfmt.width != 800) in sd_isoc_init()
3452 gspca_dev->cam.bulk_size = OVFX2_BULK_SIZE; in sd_isoc_init()
3454 gspca_dev->cam.bulk_size = 7 * 4096; in sd_isoc_init()
3462 * Do not put any sensor-specific code in here (including I2C I/O functions)
3469 struct usb_host_interface *alt; in ov511_mode_init_regs() local
3472 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); in ov511_mode_init_regs()
3473 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); in ov511_mode_init_regs()
3474 if (!alt) { in ov511_mode_init_regs()
3476 sd->gspca_dev.usb_err = -EIO; in ov511_mode_init_regs()
3480 if (alt->desc.bNumEndpoints < 1) { in ov511_mode_init_regs()
3481 sd->gspca_dev.usb_err = -ENODEV; in ov511_mode_init_regs()
3485 packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); in ov511_mode_init_regs()
3493 * I hope that's always true. --claudio in ov511_mode_init_regs()
3495 hsegs = (sd->gspca_dev.pixfmt.width >> 3) - 1; in ov511_mode_init_regs()
3496 vsegs = (sd->gspca_dev.pixfmt.height >> 3) - 1; in ov511_mode_init_regs()
3514 sd->frame_rate = frame_rate; in ov511_mode_init_regs()
3516 switch (sd->sensor) { in ov511_mode_init_regs()
3519 sd->clockdiv = 3; in ov511_mode_init_regs()
3529 if (sd->gspca_dev.pixfmt.width == 320) in ov511_mode_init_regs()
3535 switch (sd->frame_rate) { in ov511_mode_init_regs()
3539 if (sd->gspca_dev.pixfmt.width != 640) { in ov511_mode_init_regs()
3540 sd->clockdiv = 0; in ov511_mode_init_regs()
3548 sd->clockdiv = 1; in ov511_mode_init_regs()
3551 sd->clockdiv = 2; in ov511_mode_init_regs()
3554 sd->clockdiv = 5; in ov511_mode_init_regs()
3558 sd->clockdiv = (sd->clockdiv + 1) * 2 - 1; in ov511_mode_init_regs()
3560 if (sd->clockdiv > 10) in ov511_mode_init_regs()
3561 sd->clockdiv = 10; in ov511_mode_init_regs()
3567 sd->clockdiv = 0; in ov511_mode_init_regs()
3572 fps = (interlaced ? 60 : 30) / (sd->clockdiv + 1) + 1; in ov511_mode_init_regs()
3573 needed = fps * sd->gspca_dev.pixfmt.width * in ov511_mode_init_regs()
3574 sd->gspca_dev.pixfmt.height * 3 / 2; in ov511_mode_init_regs()
3594 * Do not put any sensor-specific code in here (including I2C I/O functions)
3600 struct usb_host_interface *alt; in ov518_mode_init_regs() local
3603 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); in ov518_mode_init_regs()
3604 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); in ov518_mode_init_regs()
3605 if (!alt) { in ov518_mode_init_regs()
3607 sd->gspca_dev.usb_err = -EIO; in ov518_mode_init_regs()
3611 if (alt->desc.bNumEndpoints < 1) { in ov518_mode_init_regs()
3612 sd->gspca_dev.usb_err = -ENODEV; in ov518_mode_init_regs()
3616 packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); in ov518_mode_init_regs()
3629 if (sd->bridge == BRIDGE_OV518) { in ov518_mode_init_regs()
3630 /* Set 8-bit (YVYU) input format */ in ov518_mode_init_regs()
3633 /* Set 12-bit (4:2:0) output format */ in ov518_mode_init_regs()
3641 hsegs = sd->gspca_dev.pixfmt.width / 16; in ov518_mode_init_regs()
3642 vsegs = sd->gspca_dev.pixfmt.height / 4; in ov518_mode_init_regs()
3654 if (sd->bridge == BRIDGE_OV518PLUS && sd->revision == 0 && in ov518_mode_init_regs()
3655 sd->sensor == SEN_OV7620AE) in ov518_mode_init_regs()
3656 sd->clockdiv = 0; in ov518_mode_init_regs()
3658 sd->clockdiv = 1; in ov518_mode_init_regs()
3666 if (sd->bridge == BRIDGE_OV518PLUS) { in ov518_mode_init_regs()
3667 switch (sd->sensor) { in ov518_mode_init_regs()
3681 if (sd->revision > 0 && in ov518_mode_init_regs()
3682 sd->gspca_dev.pixfmt.width == 640) { in ov518_mode_init_regs()
3698 reg_w(sd, 0x71, 0x17); /* Compression-related? */ in ov518_mode_init_regs()
3700 /* FIXME: Sensor-specific */ in ov518_mode_init_regs()
3706 if (sd->bridge == BRIDGE_OV518PLUS) { in ov518_mode_init_regs()
3740 * Do not put any sensor-specific code in here (including I2C I/O functions)
3746 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ in ov519_mode_init_regs()
3748 { 0xa2, 0x20 }, /* a2-a5 are undocumented */ in ov519_mode_init_regs()
3769 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ in ov519_mode_init_regs()
3771 { 0xa2, 0x20 }, /* a2-a5 are undocumented */ in ov519_mode_init_regs()
3791 switch (sd->sensor) { in ov519_mode_init_regs()
3794 if (sd->sensor == SEN_OV7640 || in ov519_mode_init_regs()
3795 sd->sensor == SEN_OV7648) { in ov519_mode_init_regs()
3796 /* Select 8-bit input mode */ in ov519_mode_init_regs()
3808 reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.pixfmt.width >> 4); in ov519_mode_init_regs()
3809 reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.pixfmt.height >> 3); in ov519_mode_init_regs()
3810 if (sd->sensor == SEN_OV7670 && in ov519_mode_init_regs()
3811 sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv) in ov519_mode_init_regs()
3813 else if (sd->sensor == SEN_OV7648 && in ov519_mode_init_regs()
3814 sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv) in ov519_mode_init_regs()
3827 sd->frame_rate = frame_rate; in ov519_mode_init_regs()
3830 sd->clockdiv = 0; in ov519_mode_init_regs()
3831 switch (sd->sensor) { in ov519_mode_init_regs()
3834 switch (sd->frame_rate) { in ov519_mode_init_regs()
3851 sd->clockdiv = 1; in ov519_mode_init_regs()
3856 sd->clockdiv = 1; in ov519_mode_init_regs()
3861 sd->clockdiv = 1; in ov519_mode_init_regs()
3866 switch (sd->frame_rate) { in ov519_mode_init_regs()
3884 (sd->frame_rate == 0) ? 15 : sd->frame_rate); in ov519_mode_init_regs()
3886 switch (sd->frame_rate) { in ov519_mode_init_regs()
3896 sd->clockdiv = 1; in ov519_mode_init_regs()
3909 qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; in mode_init_ov_sensor_regs()
3912 switch (sd->sensor) { in mode_init_ov_sensor_regs()
3931 if (sd->frame_rate < 25) in mode_init_ov_sensor_regs()
3934 if (sd->frame_rate < 10) in mode_init_ov_sensor_regs()
3943 xstart = (1040 - gspca_dev->pixfmt.width) / 2 + in mode_init_ov_sensor_regs()
3945 ystart = (776 - gspca_dev->pixfmt.height) / 2; in mode_init_ov_sensor_regs()
3947 xstart = (2076 - gspca_dev->pixfmt.width) / 2 + in mode_init_ov_sensor_regs()
3949 ystart = (1544 - gspca_dev->pixfmt.height) / 2; in mode_init_ov_sensor_regs()
3951 xend = xstart + gspca_dev->pixfmt.width; in mode_init_ov_sensor_regs()
3952 yend = ystart + gspca_dev->pixfmt.height; in mode_init_ov_sensor_regs()
3993 if (sd->sensor == SEN_OV76BE) in mode_init_ov_sensor_regs()
4080 vals = sd->frame_rate < 30 ? vga_15 : vga_30; in mode_init_ov_sensor_regs()
4082 vals = sd->frame_rate < 15 ? sxga_7_5 : sxga_15; in mode_init_ov_sensor_regs()
4091 i2c_w(sd, 0x11, sd->clockdiv); in mode_init_ov_sensor_regs()
4099 if (sd->gspca_dev.streaming) in sethvflip()
4104 if (sd->gspca_dev.streaming) in sethvflip()
4115 switch (sd->sensor) { in set_ov_sensor_window()
4129 gspca_dev = &sd->gspca_dev; in set_ov_sensor_window()
4130 qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; in set_ov_sensor_window()
4131 crop = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 2; in set_ov_sensor_window()
4135 switch (sd->sensor) { in set_ov_sensor_window()
4155 if (sd->sensor == SEN_OV66308AF && qvga) in set_ov_sensor_window()
4181 switch (sd->sensor) { in set_ov_sensor_window()
4216 i2c_w(sd, 0x18, hwebase + (sd->sensor_width >> hwscale)); in set_ov_sensor_window()
4218 i2c_w(sd, 0x1a, vwebase + (sd->sensor_height >> vwscale)); in set_ov_sensor_window()
4221 /* -- start the camera -- */
4227 sd->sensor_width = sd->gspca_dev.pixfmt.width; in sd_start()
4228 sd->sensor_height = sd->gspca_dev.pixfmt.height; in sd_start()
4230 switch (sd->bridge) { in sd_start()
4252 sd->snapshot_needs_reset = 1; in sd_start()
4255 sd->first_frame = 3; in sd_start()
4259 return gspca_dev->usb_err; in sd_start()
4274 if (!sd->gspca_dev.present) in sd_stop0()
4276 if (sd->bridge == BRIDGE_W9968CF) in sd_stop0()
4281 if (sd->snapshot_pressed) { in sd_stop0()
4282 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); in sd_stop0()
4283 input_sync(gspca_dev->input_dev); in sd_stop0()
4284 sd->snapshot_pressed = 0; in sd_stop0()
4287 if (sd->bridge == BRIDGE_OV519) in sd_stop0()
4295 if (sd->snapshot_pressed != state) { in ov51x_handle_button()
4297 input_report_key(gspca_dev->input_dev, KEY_CAMERA, state); in ov51x_handle_button()
4298 input_sync(gspca_dev->input_dev); in ov51x_handle_button()
4301 sd->snapshot_needs_reset = 1; in ov51x_handle_button()
4303 sd->snapshot_pressed = state; in ov51x_handle_button()
4308 switch (sd->bridge) { in ov51x_handle_button()
4313 sd->snapshot_needs_reset = 1; in ov51x_handle_button()
4326 * byte non-zero. The EOF packet has image width/height in the in ov511_pkt_scan()
4343 if ((in[9] + 1) * 8 != gspca_dev->pixfmt.width || in ov511_pkt_scan()
4344 (in[10] + 1) * 8 != gspca_dev->pixfmt.height) { in ov511_pkt_scan()
4347 gspca_dev->pixfmt.width, in ov511_pkt_scan()
4348 gspca_dev->pixfmt.height); in ov511_pkt_scan()
4349 gspca_dev->last_packet_type = DISCARD_PACKET; in ov511_pkt_scan()
4358 sd->packet_nr = 0; in ov511_pkt_scan()
4363 len--; in ov511_pkt_scan()
4381 sd->packet_nr = 0; in ov518_pkt_scan()
4384 if (gspca_dev->last_packet_type == DISCARD_PACKET) in ov518_pkt_scan()
4389 len--; in ov518_pkt_scan()
4390 if (sd->packet_nr == data[len]) in ov518_pkt_scan()
4391 sd->packet_nr++; in ov518_pkt_scan()
4395 else if (sd->packet_nr == 0 || data[len]) { in ov518_pkt_scan()
4397 (int)data[len], (int)sd->packet_nr); in ov518_pkt_scan()
4398 gspca_dev->last_packet_type = DISCARD_PACKET; in ov518_pkt_scan()
4431 len -= HDRSZ; in ov519_pkt_scan()
4437 gspca_dev->last_packet_type = DISCARD_PACKET; in ov519_pkt_scan()
4442 gspca_dev->last_packet_type = DISCARD_PACKET; in ov519_pkt_scan()
4462 if (len < gspca_dev->cam.bulk_size) { in ovfx2_pkt_scan()
4465 if (sd->first_frame) { in ovfx2_pkt_scan()
4466 sd->first_frame--; in ovfx2_pkt_scan()
4467 if (gspca_dev->image_len < in ovfx2_pkt_scan()
4468 sd->gspca_dev.pixfmt.width * in ovfx2_pkt_scan()
4469 sd->gspca_dev.pixfmt.height) in ovfx2_pkt_scan()
4470 gspca_dev->last_packet_type = DISCARD_PACKET; in ovfx2_pkt_scan()
4483 switch (sd->bridge) { in sd_pkt_scan()
4504 /* -- management routines -- */
4526 switch (sd->sensor) { in setbrightness()
4615 switch (sd->sensor) { in setcontrast()
4678 switch (sd->sensor) { in setcolors()
4690 /* rc = ov_i2c_write(sd->dev, 0x62, (val >> 9) & 0x7e); in setcolors()
4720 if (sd->sensor == SEN_OV7660 in setfreq_i()
4721 || sd->sensor == SEN_OV7670) { in setfreq_i()
4736 case 3: /* Auto hz - ov7670 only */ in setfreq_i()
4752 /* 20 fps -> 16.667 fps */ in setfreq_i()
4753 if (sd->sensor == SEN_OV6620 || in setfreq_i()
4754 sd->sensor == SEN_OV6630 || in setfreq_i()
4755 sd->sensor == SEN_OV66308AF) in setfreq_i()
4762 if (sd->sensor == SEN_OV6620 || in setfreq_i()
4763 sd->sensor == SEN_OV6630 || in setfreq_i()
4764 sd->sensor == SEN_OV66308AF) { in setfreq_i()
4765 /* 20 fps -> 15 fps */ in setfreq_i()
4784 if (sd->bridge == BRIDGE_W9968CF) in setfreq()
4793 if (sd->bridge != BRIDGE_W9968CF) in sd_get_jcomp()
4794 return -ENOTTY; in sd_get_jcomp()
4797 jcomp->quality = v4l2_ctrl_g_ctrl(sd->jpegqual); in sd_get_jcomp()
4798 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT | in sd_get_jcomp()
4808 if (sd->bridge != BRIDGE_W9968CF) in sd_set_jcomp()
4809 return -ENOTTY; in sd_set_jcomp()
4811 v4l2_ctrl_s_ctrl(sd->jpegqual, jcomp->quality); in sd_set_jcomp()
4818 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_g_volatile_ctrl()
4821 gspca_dev->usb_err = 0; in sd_g_volatile_ctrl()
4823 switch (ctrl->id) { in sd_g_volatile_ctrl()
4825 gspca_dev->exposure->val = i2c_r(sd, 0x10); in sd_g_volatile_ctrl()
4834 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
4837 gspca_dev->usb_err = 0; in sd_s_ctrl()
4839 if (!gspca_dev->streaming) in sd_s_ctrl()
4842 switch (ctrl->id) { in sd_s_ctrl()
4844 setbrightness(gspca_dev, ctrl->val); in sd_s_ctrl()
4847 setcontrast(gspca_dev, ctrl->val); in sd_s_ctrl()
4850 setfreq(gspca_dev, ctrl->val); in sd_s_ctrl()
4853 if (ctrl->is_new) in sd_s_ctrl()
4854 setautobright(gspca_dev, ctrl->val); in sd_s_ctrl()
4855 if (!ctrl->val && sd->brightness->is_new) in sd_s_ctrl()
4856 setbrightness(gspca_dev, sd->brightness->val); in sd_s_ctrl()
4859 setcolors(gspca_dev, ctrl->val); in sd_s_ctrl()
4862 sethvflip(gspca_dev, ctrl->val, sd->vflip->val); in sd_s_ctrl()
4865 if (ctrl->is_new) in sd_s_ctrl()
4866 setautogain(gspca_dev, ctrl->val); in sd_s_ctrl()
4867 if (!ctrl->val && gspca_dev->exposure->is_new) in sd_s_ctrl()
4868 setexposure(gspca_dev, gspca_dev->exposure->val); in sd_s_ctrl()
4871 return -EBUSY; /* Should never happen, as we grab the ctrl */ in sd_s_ctrl()
4873 return gspca_dev->usb_err; in sd_s_ctrl()
4884 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
4886 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
4888 if (valid_controls[sd->sensor].has_brightness) in sd_init_controls()
4889 sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4891 sd->sensor == SEN_OV7660 ? 6 : 255, 1, in sd_init_controls()
4892 sd->sensor == SEN_OV7660 ? 3 : 127); in sd_init_controls()
4893 if (valid_controls[sd->sensor].has_contrast) { in sd_init_controls()
4894 if (sd->sensor == SEN_OV7660) in sd_init_controls()
4900 (sd->sensor == SEN_OV6630 || in sd_init_controls()
4901 sd->sensor == SEN_OV66308AF) ? 200 : 127); in sd_init_controls()
4903 if (valid_controls[sd->sensor].has_sat) in sd_init_controls()
4906 sd->sensor == SEN_OV7660 ? 4 : 255, 1, in sd_init_controls()
4907 sd->sensor == SEN_OV7660 ? 2 : 127); in sd_init_controls()
4908 if (valid_controls[sd->sensor].has_exposure) in sd_init_controls()
4909 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4911 if (valid_controls[sd->sensor].has_hvflip) { in sd_init_controls()
4912 sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4914 sd->vflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4917 if (valid_controls[sd->sensor].has_autobright) in sd_init_controls()
4918 sd->autobright = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4920 if (valid_controls[sd->sensor].has_autogain) in sd_init_controls()
4921 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4923 if (valid_controls[sd->sensor].has_freq) { in sd_init_controls()
4924 if (sd->sensor == SEN_OV7670) in sd_init_controls()
4925 sd->freq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops, in sd_init_controls()
4930 sd->freq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops, in sd_init_controls()
4934 if (sd->bridge == BRIDGE_W9968CF) in sd_init_controls()
4935 sd->jpegqual = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4939 if (hdl->error) { in sd_init_controls()
4941 return hdl->error; in sd_init_controls()
4943 if (gspca_dev->autogain) in sd_init_controls()
4944 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, true); in sd_init_controls()
4945 if (sd->autobright) in sd_init_controls()
4946 v4l2_ctrl_auto_cluster(2, &sd->autobright, 0, false); in sd_init_controls()
4947 if (sd->hflip) in sd_init_controls()
4948 v4l2_ctrl_cluster(2, &sd->hflip); in sd_init_controls()
4952 /* sub-driver description */
4971 /* -- module initialisation -- */
5007 /* -- device connect -- */