Lines Matching refs:gspca_dev
111 struct gspca_dev gspca_dev; /* !! must be the first item */ member
975 static void reg_w(struct gspca_dev *gspca_dev, u8 index, u8 value) in reg_w() argument
977 struct usb_device *dev = gspca_dev->dev; in reg_w()
980 if (gspca_dev->usb_err < 0) in reg_w()
988 gspca_dev->usb_err = ret; in reg_w()
993 static void reg_r(struct gspca_dev *gspca_dev, u8 index) in reg_r() argument
995 struct usb_device *dev = gspca_dev->dev; in reg_r()
998 if (gspca_dev->usb_err < 0) in reg_r()
1003 0, index, gspca_dev->usb_buf, 1, 500); in reg_r()
1006 gspca_dev->usb_err = ret; in reg_r()
1010 static void reg_w_buf(struct gspca_dev *gspca_dev, in reg_w_buf() argument
1014 reg_w(gspca_dev, p->reg, p->val); in reg_w_buf()
1019 static int i2c_w(struct gspca_dev *gspca_dev, u8 index, u8 value) in i2c_w() argument
1021 struct sd *sd = (struct sd *) gspca_dev; in i2c_w()
1023 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x00); in i2c_w()
1024 reg_w(gspca_dev, TP6800_R19_SIF_ADDR_S2, index); in i2c_w()
1025 reg_w(gspca_dev, TP6800_R13_SIF_TX_DATA, value); in i2c_w()
1026 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x01); in i2c_w()
1030 reg_r(gspca_dev, TP6800_R11_SIF_CONTROL); in i2c_w()
1031 if (gspca_dev->usb_buf[0] == 0) in i2c_w()
1033 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x00); in i2c_w()
1037 static void i2c_w_buf(struct gspca_dev *gspca_dev, in i2c_w_buf() argument
1041 i2c_w(gspca_dev, p->reg, p->val); in i2c_w_buf()
1046 static int i2c_r(struct gspca_dev *gspca_dev, u8 index, int len) in i2c_r() argument
1048 struct sd *sd = (struct sd *) gspca_dev; in i2c_r()
1051 reg_w(gspca_dev, TP6800_R19_SIF_ADDR_S2, index); in i2c_r()
1052 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x02); in i2c_r()
1054 reg_r(gspca_dev, TP6800_R14_SIF_RX_DATA); in i2c_r()
1055 v = gspca_dev->usb_buf[0]; in i2c_r()
1059 reg_r(gspca_dev, TP6800_R1B_SIF_RX_DATA2); in i2c_r()
1060 v |= (gspca_dev->usb_buf[0] << 8); in i2c_r()
1062 reg_r(gspca_dev, TP6800_R11_SIF_CONTROL); in i2c_r()
1063 if (gspca_dev->usb_buf[0] == 0) in i2c_r()
1065 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x00); in i2c_r()
1069 static void bulk_w(struct gspca_dev *gspca_dev, in bulk_w() argument
1074 struct usb_device *dev = gspca_dev->dev; in bulk_w()
1077 if (gspca_dev->usb_err < 0) in bulk_w()
1082 gspca_dev->usb_buf[0] = tag; in bulk_w()
1083 memcpy(&gspca_dev->usb_buf[1], data, count); in bulk_w()
1086 gspca_dev->usb_buf, count + 1, in bulk_w()
1091 gspca_dev->usb_err = ret; in bulk_w()
1101 static int probe_6810(struct gspca_dev *gspca_dev) in probe_6810() argument
1106 reg_r(gspca_dev, TP6800_R18_GPIO_DATA); in probe_6810()
1107 gpio = gspca_dev->usb_buf[0]; in probe_6810()
1108 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1109 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1110 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1111 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x04); /* i2c 16 bits */ in probe_6810()
1112 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x21); /* ov??? */ in probe_6810()
1113 reg_w(gspca_dev, TP6800_R1A_SIF_TX_DATA2, 0x00); in probe_6810()
1114 if (i2c_w(gspca_dev, 0x00, 0x00) >= 0) in probe_6810()
1117 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1118 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x00); /* i2c 8 bits */ in probe_6810()
1119 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x7f); /* (unknown i2c) */ in probe_6810()
1120 if (i2c_w(gspca_dev, 0x00, 0x00) >= 0) in probe_6810()
1123 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1124 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1125 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1126 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x00); /* i2c 8 bits */ in probe_6810()
1127 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x11); /* tas??? / hv??? */ in probe_6810()
1128 ret = i2c_r(gspca_dev, 0x00, 1); in probe_6810()
1132 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1133 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1134 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1135 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x6e); /* po??? */ in probe_6810()
1136 ret = i2c_r(gspca_dev, 0x00, 1); in probe_6810()
1140 ret = i2c_r(gspca_dev, 0x01, 1); in probe_6810()
1144 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1145 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1146 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1147 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x04); /* i2c 16 bits */ in probe_6810()
1148 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x5d); /* mi/mt??? */ in probe_6810()
1149 ret = i2c_r(gspca_dev, 0x00, 2); in probe_6810()
1153 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1154 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1155 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1156 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x5c); /* mi/mt??? */ in probe_6810()
1157 ret = i2c_r(gspca_dev, 0x36, 2); in probe_6810()
1161 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1162 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1163 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1164 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x61); /* (unknown i2c) */ in probe_6810()
1165 reg_w(gspca_dev, TP6800_R1A_SIF_TX_DATA2, 0x10); in probe_6810()
1166 if (i2c_w(gspca_dev, 0xff, 0x00) >= 0) in probe_6810()
1169 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1170 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1171 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1172 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x00); /* i2c 8 bits */ in probe_6810()
1173 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x20); /* cx0342 */ in probe_6810()
1174 ret = i2c_r(gspca_dev, 0x00, 1); in probe_6810()
1180 static void cx0342_6810_init(struct gspca_dev *gspca_dev) in cx0342_6810_init() argument
1232 reg_w_buf(gspca_dev, reg_init_1, ARRAY_SIZE(reg_init_1)); in cx0342_6810_init()
1233 reg_w_buf(gspca_dev, tp6810_cx_init_common, in cx0342_6810_init()
1235 reg_w_buf(gspca_dev, reg_init_2, ARRAY_SIZE(reg_init_2)); in cx0342_6810_init()
1237 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x20); /* cx0342 I2C addr */ in cx0342_6810_init()
1238 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in cx0342_6810_init()
1239 i2c_w_buf(gspca_dev, cx0342_timing_seq, ARRAY_SIZE(cx0342_timing_seq)); in cx0342_6810_init()
1242 static void soi763a_6810_init(struct gspca_dev *gspca_dev) in soi763a_6810_init() argument
1387 reg_w_buf(gspca_dev, reg_init_1, ARRAY_SIZE(reg_init_1)); in soi763a_6810_init()
1388 reg_w_buf(gspca_dev, tp6810_ov_init_common, in soi763a_6810_init()
1390 reg_w_buf(gspca_dev, reg_init_2, ARRAY_SIZE(reg_init_2)); in soi763a_6810_init()
1392 i2c_w(gspca_dev, 0x12, 0x80); /* sensor reset */ in soi763a_6810_init()
1394 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in soi763a_6810_init()
1398 static void setexposure(struct gspca_dev *gspca_dev, s32 expo, s32 gain, in setexposure() argument
1401 struct sd *sd = (struct sd *) gspca_dev; in setexposure()
1405 i2c_w(gspca_dev, CX0342_EXPO_LINE_L, expo); in setexposure()
1406 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, expo >> 8); in setexposure()
1408 i2c_w(gspca_dev, CX0342_RAW_GBGAIN_H, in setexposure()
1410 i2c_w(gspca_dev, CX0342_RAW_GBGAIN_L, gain); in setexposure()
1412 i2c_w(gspca_dev, CX0342_RAW_GRGAIN_H, in setexposure()
1414 i2c_w(gspca_dev, CX0342_RAW_GRGAIN_L, gain); in setexposure()
1417 i2c_w(gspca_dev, CX0342_RAW_BGAIN_H, in setexposure()
1419 i2c_w(gspca_dev, CX0342_RAW_BGAIN_L, blue); in setexposure()
1421 i2c_w(gspca_dev, CX0342_RAW_RGAIN_H, in setexposure()
1423 i2c_w(gspca_dev, CX0342_RAW_RGAIN_L, red); in setexposure()
1425 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, in setexposure()
1431 i2c_w(gspca_dev, 0x10, /* AEC_H (exposure time) */ in setexposure()
1434 i2c_w(gspca_dev, 0x00, /* gain */ in setexposure()
1439 static void set_dqt(struct gspca_dev *gspca_dev, u8 q) in set_dqt() argument
1441 struct sd *sd = (struct sd *) gspca_dev; in set_dqt()
1444 gspca_dbg(gspca_dev, D_STREAM, "q %d -> %d\n", sd->quality, q); in set_dqt()
1456 static void setquality(struct gspca_dev *gspca_dev, s32 q) in setquality() argument
1458 struct sd *sd = (struct sd *) gspca_dev; in setquality()
1463 reg_w(gspca_dev, TP6800_R7A_BLK_THRLD, 0x00); in setquality()
1464 reg_w(gspca_dev, TP6800_R79_QUALITY, 0x04); in setquality()
1465 reg_w(gspca_dev, TP6800_R79_QUALITY, q); in setquality()
1470 reg_w(gspca_dev, TP6800_R7A_BLK_THRLD, 0x19); in setquality()
1490 static void setgamma(struct gspca_dev *gspca_dev, s32 gamma) in setgamma() argument
1492 struct sd *sd = (struct sd *) gspca_dev; in setgamma()
3813 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); in setgamma()
3815 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3817 bulk_w(gspca_dev, 0x00, gamma_tb[gamma][0], 1024); in setgamma()
3818 bulk_w(gspca_dev, 0x01, gamma_tb[gamma][1], 1024); in setgamma()
3819 bulk_w(gspca_dev, 0x02, gamma_tb[gamma][2], 1024); in setgamma()
3823 reg_w(gspca_dev, 0x02, 0x2b); in setgamma()
3824 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3826 reg_w(gspca_dev, TP6800_R55_GAMMA_R, in setgamma()
3828 reg_w(gspca_dev, 0x02, 0x2b); in setgamma()
3829 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3831 reg_w(gspca_dev, TP6800_R56_GAMMA_G, in setgamma()
3833 reg_w(gspca_dev, 0x02, 0x2b); in setgamma()
3834 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3836 reg_w(gspca_dev, TP6800_R57_GAMMA_B, in setgamma()
3838 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3840 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x03); in setgamma()
3844 static void setsharpness(struct gspca_dev *gspca_dev, s32 val) in setsharpness() argument
3846 struct sd *sd = (struct sd *) gspca_dev; in setsharpness()
3850 if (gspca_dev->pixfmt.width == 640) in setsharpness()
3851 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in setsharpness()
3854 reg_w(gspca_dev, TP6800_R5D_DEMOSAIC_CFG, val); in setsharpness()
3857 reg_w(gspca_dev, 0x59, val); in setsharpness()
3861 static void setautogain(struct gspca_dev *gspca_dev, s32 val) in setautogain() argument
3863 struct sd *sd = (struct sd *) gspca_dev; in setautogain()
3869 static void set_resolution(struct gspca_dev *gspca_dev) in set_resolution() argument
3871 struct sd *sd = (struct sd *) gspca_dev; in set_resolution()
3873 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); in set_resolution()
3874 if (gspca_dev->pixfmt.width == 320) { in set_resolution()
3875 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x06); in set_resolution()
3877 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); in set_resolution()
3879 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x03); in set_resolution()
3880 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x01); /* qvga */ in set_resolution()
3881 reg_w(gspca_dev, TP6800_R5D_DEMOSAIC_CFG, 0x0d); in set_resolution()
3882 i2c_w(gspca_dev, CX0342_EXPO_LINE_L, 0x37); in set_resolution()
3883 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, 0x01); in set_resolution()
3885 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x05); in set_resolution()
3887 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); in set_resolution()
3889 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x03); in set_resolution()
3890 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in set_resolution()
3891 reg_w(gspca_dev, TP6800_R5D_DEMOSAIC_CFG, 0x09); in set_resolution()
3892 i2c_w(gspca_dev, CX0342_EXPO_LINE_L, 0xcf); in set_resolution()
3893 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, 0x00); in set_resolution()
3895 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x01); in set_resolution()
3896 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_CX0342], in set_resolution()
3898 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in set_resolution()
3900 setquality(gspca_dev, v4l2_ctrl_g_ctrl(sd->jpegqual)); in set_resolution()
3904 static int get_fr_idx(struct gspca_dev *gspca_dev) in get_fr_idx() argument
3906 struct sd *sd = (struct sd *) gspca_dev; in get_fr_idx()
3918 && gspca_dev->pixfmt.width == 640) in get_fr_idx()
3929 && gspca_dev->pixfmt.width == 640) in get_fr_idx()
3936 static void setframerate(struct gspca_dev *gspca_dev, s32 val) in setframerate() argument
3938 struct sd *sd = (struct sd *) gspca_dev; in setframerate()
3941 fr_idx = get_fr_idx(gspca_dev); in setframerate()
3944 reg_r(gspca_dev, 0x7b); in setframerate()
3945 reg_w(gspca_dev, 0x7b, in setframerate()
3951 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, fr_idx); in setframerate()
3954 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); in setframerate()
3957 static void setrgain(struct gspca_dev *gspca_dev, s32 rgain) in setrgain() argument
3959 i2c_w(gspca_dev, CX0342_RAW_RGAIN_H, rgain >> 8); in setrgain()
3960 i2c_w(gspca_dev, CX0342_RAW_RGAIN_L, rgain); in setrgain()
3961 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x80); in setrgain()
3964 static int sd_setgain(struct gspca_dev *gspca_dev) in sd_setgain() argument
3966 struct sd *sd = (struct sd *) gspca_dev; in sd_setgain()
3967 s32 val = gspca_dev->gain->val; in sd_setgain()
3970 s32 old = gspca_dev->gain->cur.val ? in sd_setgain()
3971 gspca_dev->gain->cur.val : 1; in sd_setgain()
3980 if (gspca_dev->streaming) { in sd_setgain()
3982 setexposure(gspca_dev, gspca_dev->exposure->val, in sd_setgain()
3983 gspca_dev->gain->val, in sd_setgain()
3986 setexposure(gspca_dev, gspca_dev->exposure->val, in sd_setgain()
3987 gspca_dev->gain->val, 0, 0); in sd_setgain()
3989 return gspca_dev->usb_err; in sd_setgain()
3992 static void setbgain(struct gspca_dev *gspca_dev, s32 bgain) in setbgain() argument
3994 i2c_w(gspca_dev, CX0342_RAW_BGAIN_H, bgain >> 8); in setbgain()
3995 i2c_w(gspca_dev, CX0342_RAW_BGAIN_L, bgain); in setbgain()
3996 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x80); in setbgain()
4000 static int sd_config(struct gspca_dev *gspca_dev, in sd_config() argument
4003 struct sd *sd = (struct sd *) gspca_dev; in sd_config()
4007 gspca_dev->cam.cam_mode = vga_mode; in sd_config()
4008 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode); in sd_config()
4009 gspca_dev->cam.mode_framerates = sd->bridge == BRIDGE_TP6800 ? in sd_config()
4017 static int sd_init(struct gspca_dev *gspca_dev) in sd_init() argument
4019 struct sd *sd = (struct sd *) gspca_dev; in sd_init()
4037 reg_w_buf(gspca_dev, tp6800_preinit, in sd_init()
4040 reg_w_buf(gspca_dev, tp6810_preinit, in sd_init()
4043 reg_r(gspca_dev, TP6800_R18_GPIO_DATA); in sd_init()
4044 gspca_dbg(gspca_dev, D_PROBE, "gpio: %02x\n", gspca_dev->usb_buf[0]); in sd_init()
4058 switch (gspca_dev->usb_buf[0] & 0x07) { in sd_init()
4069 sensor = probe_6810(gspca_dev); in sd_init()
4081 soi763a_6810_init(gspca_dev); in sd_init()
4086 cx0342_6810_init(gspca_dev); in sd_init()
4090 set_dqt(gspca_dev, 0); in sd_init()
4095 static int sd_isoc_init(struct gspca_dev *gspca_dev) in sd_isoc_init() argument
4097 struct sd *sd = (struct sd *) gspca_dev; in sd_isoc_init()
4127 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x20); in sd_isoc_init()
4128 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x87); in sd_isoc_init()
4129 i2c_w_buf(gspca_dev, cx_sensor_init, in sd_isoc_init()
4131 reg_w_buf(gspca_dev, cx_bridge_init, in sd_isoc_init()
4133 bulk_w(gspca_dev, 0x03, color_null, sizeof color_null); in sd_isoc_init()
4134 reg_w(gspca_dev, 0x59, 0x40); in sd_isoc_init()
4136 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x21); in sd_isoc_init()
4137 i2c_w_buf(gspca_dev, ov_sensor_init, in sd_isoc_init()
4139 reg_r(gspca_dev, 0x7b); in sd_isoc_init()
4140 reg_w_buf(gspca_dev, ov_bridge_init, in sd_isoc_init()
4143 reg_w(gspca_dev, TP6800_R78_FORMAT, in sd_isoc_init()
4144 gspca_dev->curr_mode ? 0x00 : 0x01); in sd_isoc_init()
4145 return gspca_dev->usb_err; in sd_isoc_init()
4148 static void set_led(struct gspca_dev *gspca_dev, int on) in set_led() argument
4152 reg_r(gspca_dev, TP6800_R18_GPIO_DATA); in set_led()
4153 data = gspca_dev->usb_buf[0]; in set_led()
4158 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, data); in set_led()
4161 static void cx0342_6800_start(struct gspca_dev *gspca_dev) in cx0342_6800_start() argument
4163 struct sd *sd = (struct sd *) gspca_dev; in cx0342_6800_start()
4229 reg_w_buf(gspca_dev, reg_init, ARRAY_SIZE(reg_init)); in cx0342_6800_start()
4230 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in cx0342_6800_start()
4231 i2c_w_buf(gspca_dev, cx0342_timing_seq, ARRAY_SIZE(cx0342_timing_seq)); in cx0342_6800_start()
4232 reg_w(gspca_dev, TP6800_R5C_EDGE_THRLD, 0x10); in cx0342_6800_start()
4233 reg_w(gspca_dev, TP6800_R54_DARK_CFG, 0x00); in cx0342_6800_start()
4234 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, 0x00); in cx0342_6800_start()
4235 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x01); in cx0342_6800_start()
4237 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in cx0342_6800_start()
4238 v4l2_ctrl_g_ctrl(gspca_dev->gain), in cx0342_6800_start()
4242 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in cx0342_6800_start()
4243 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in cx0342_6800_start()
4244 set_led(gspca_dev, 1); in cx0342_6800_start()
4245 set_resolution(gspca_dev); in cx0342_6800_start()
4248 static void cx0342_6810_start(struct gspca_dev *gspca_dev) in cx0342_6810_start() argument
4250 struct sd *sd = (struct sd *) gspca_dev; in cx0342_6810_start()
4316 reg_w(gspca_dev, 0x22, gspca_dev->alt); in cx0342_6810_start()
4317 i2c_w_buf(gspca_dev, sensor_init_2, ARRAY_SIZE(sensor_init_2)); in cx0342_6810_start()
4318 reg_w_buf(gspca_dev, bridge_init_2, ARRAY_SIZE(bridge_init_2)); in cx0342_6810_start()
4319 reg_w_buf(gspca_dev, tp6810_cx_init_common, in cx0342_6810_start()
4321 reg_w_buf(gspca_dev, bridge_init_3, ARRAY_SIZE(bridge_init_3)); in cx0342_6810_start()
4322 if (gspca_dev->curr_mode) { in cx0342_6810_start()
4323 reg_w(gspca_dev, 0x4a, 0x7f); in cx0342_6810_start()
4324 reg_w(gspca_dev, 0x07, 0x05); in cx0342_6810_start()
4325 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in cx0342_6810_start()
4327 reg_w(gspca_dev, 0x4a, 0xff); in cx0342_6810_start()
4328 reg_w(gspca_dev, 0x07, 0x85); in cx0342_6810_start()
4329 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x01); /* qvga */ in cx0342_6810_start()
4331 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in cx0342_6810_start()
4332 reg_w_buf(gspca_dev, tp6810_bridge_start, in cx0342_6810_start()
4334 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in cx0342_6810_start()
4335 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_CX0342], in cx0342_6810_start()
4337 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x87); in cx0342_6810_start()
4338 i2c_w_buf(gspca_dev, sensor_init_3, ARRAY_SIZE(sensor_init_3)); in cx0342_6810_start()
4339 reg_w_buf(gspca_dev, bridge_init_5, ARRAY_SIZE(bridge_init_5)); in cx0342_6810_start()
4340 i2c_w_buf(gspca_dev, sensor_init_4, ARRAY_SIZE(sensor_init_4)); in cx0342_6810_start()
4341 reg_w_buf(gspca_dev, bridge_init_5, ARRAY_SIZE(bridge_init_5)); in cx0342_6810_start()
4342 i2c_w_buf(gspca_dev, sensor_init_5, ARRAY_SIZE(sensor_init_5)); in cx0342_6810_start()
4344 set_led(gspca_dev, 1); in cx0342_6810_start()
4348 static void soi763a_6800_start(struct gspca_dev *gspca_dev) in soi763a_6800_start() argument
4350 struct sd *sd = (struct sd *) gspca_dev; in soi763a_6800_start()
4440 reg_w_buf(gspca_dev, reg_init, ARRAY_SIZE(reg_init)); in soi763a_6800_start()
4442 i2c_w(gspca_dev, 0x12, 0x80); /* sensor reset */ in soi763a_6800_start()
4445 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in soi763a_6800_start()
4447 reg_w(gspca_dev, TP6800_R5C_EDGE_THRLD, 0x10); in soi763a_6800_start()
4448 reg_w(gspca_dev, TP6800_R54_DARK_CFG, 0x00); in soi763a_6800_start()
4450 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in soi763a_6800_start()
4452 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_SOI763A], in soi763a_6800_start()
4455 set_led(gspca_dev, 1); in soi763a_6800_start()
4457 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6800_start()
4458 v4l2_ctrl_g_ctrl(gspca_dev->gain), in soi763a_6800_start()
4462 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6800_start()
4463 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in soi763a_6800_start()
4465 setquality(gspca_dev, v4l2_ctrl_g_ctrl(sd->jpegqual)); in soi763a_6800_start()
4466 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in soi763a_6800_start()
4469 static void soi763a_6810_start(struct gspca_dev *gspca_dev) in soi763a_6810_start() argument
4471 struct sd *sd = (struct sd *) gspca_dev; in soi763a_6810_start()
4492 reg_w(gspca_dev, 0x22, gspca_dev->alt); in soi763a_6810_start()
4493 bulk_w(gspca_dev, 0x03, color_null, sizeof color_null); in soi763a_6810_start()
4494 reg_w(gspca_dev, 0x59, 0x40); in soi763a_6810_start()
4496 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4497 v4l2_ctrl_g_ctrl(gspca_dev->gain), in soi763a_6810_start()
4501 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4502 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in soi763a_6810_start()
4503 reg_w_buf(gspca_dev, bridge_init_2, ARRAY_SIZE(bridge_init_2)); in soi763a_6810_start()
4504 reg_w_buf(gspca_dev, tp6810_ov_init_common, in soi763a_6810_start()
4506 reg_w_buf(gspca_dev, bridge_init_3, ARRAY_SIZE(bridge_init_3)); in soi763a_6810_start()
4507 if (gspca_dev->curr_mode) { in soi763a_6810_start()
4508 reg_w(gspca_dev, 0x4a, 0x7f); in soi763a_6810_start()
4509 reg_w(gspca_dev, 0x07, 0x05); in soi763a_6810_start()
4510 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in soi763a_6810_start()
4512 reg_w(gspca_dev, 0x4a, 0xff); in soi763a_6810_start()
4513 reg_w(gspca_dev, 0x07, 0x85); in soi763a_6810_start()
4514 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x01); /* qvga */ in soi763a_6810_start()
4516 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in soi763a_6810_start()
4517 reg_w_buf(gspca_dev, tp6810_bridge_start, in soi763a_6810_start()
4520 if (gspca_dev->curr_mode) { in soi763a_6810_start()
4521 reg_w(gspca_dev, 0x4f, 0x00); in soi763a_6810_start()
4522 reg_w(gspca_dev, 0x4e, 0x7c); in soi763a_6810_start()
4525 reg_w(gspca_dev, 0x00, 0x00); in soi763a_6810_start()
4527 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in soi763a_6810_start()
4528 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_SOI763A], in soi763a_6810_start()
4530 set_led(gspca_dev, 1); in soi763a_6810_start()
4531 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0xf0); in soi763a_6810_start()
4533 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4534 v4l2_ctrl_g_ctrl(gspca_dev->gain), in soi763a_6810_start()
4538 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4539 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in soi763a_6810_start()
4540 reg_w_buf(gspca_dev, bridge_init_6, ARRAY_SIZE(bridge_init_6)); in soi763a_6810_start()
4544 static int sd_start(struct gspca_dev *gspca_dev) in sd_start() argument
4546 struct sd *sd = (struct sd *) gspca_dev; in sd_start()
4548 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height, in sd_start()
4549 gspca_dev->pixfmt.width); in sd_start()
4550 set_dqt(gspca_dev, sd->quality); in sd_start()
4553 cx0342_6800_start(gspca_dev); in sd_start()
4555 soi763a_6800_start(gspca_dev); in sd_start()
4558 cx0342_6810_start(gspca_dev); in sd_start()
4560 soi763a_6810_start(gspca_dev); in sd_start()
4561 reg_w_buf(gspca_dev, tp6810_late_start, in sd_start()
4563 reg_w(gspca_dev, 0x80, 0x03); in sd_start()
4564 reg_w(gspca_dev, 0x82, gspca_dev->curr_mode ? 0x0a : 0x0e); in sd_start()
4567 setexposure(gspca_dev, in sd_start()
4568 v4l2_ctrl_g_ctrl(gspca_dev->exposure), in sd_start()
4569 v4l2_ctrl_g_ctrl(gspca_dev->gain), in sd_start()
4573 setexposure(gspca_dev, in sd_start()
4574 v4l2_ctrl_g_ctrl(gspca_dev->exposure), in sd_start()
4575 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in sd_start()
4577 setquality(gspca_dev, in sd_start()
4580 setautogain(gspca_dev, in sd_start()
4581 v4l2_ctrl_g_ctrl(gspca_dev->autogain)); in sd_start()
4584 setframerate(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); in sd_start()
4586 return gspca_dev->usb_err; in sd_start()
4589 static void sd_stopN(struct gspca_dev *gspca_dev) in sd_stopN() argument
4591 struct sd *sd = (struct sd *) gspca_dev; in sd_stopN()
4594 reg_w(gspca_dev, TP6800_R2F_TIMING_CFG, 0x03); in sd_stopN()
4595 set_led(gspca_dev, 0); in sd_stopN()
4596 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); in sd_stopN()
4599 static void sd_pkt_scan(struct gspca_dev *gspca_dev, in sd_pkt_scan() argument
4603 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan()
4618 gspca_dbg(gspca_dev, D_FRAM, "bad frame\n"); in sd_pkt_scan()
4619 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4626 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4632 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4636 set_dqt(gspca_dev, data[6] & 0x0f); in sd_pkt_scan()
4637 gspca_frame_add(gspca_dev, FIRST_PACKET, in sd_pkt_scan()
4639 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4642 gspca_frame_add(gspca_dev, LAST_PACKET, in sd_pkt_scan()
4645 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4653 gspca_frame_add(gspca_dev, LAST_PACKET, data, 0); in sd_pkt_scan()
4660 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4664 set_dqt(gspca_dev, data[7]); in sd_pkt_scan()
4665 gspca_frame_add(gspca_dev, FIRST_PACKET, in sd_pkt_scan()
4667 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4671 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4675 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4678 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4683 static void sd_dq_callback(struct gspca_dev *gspca_dev) in sd_dq_callback() argument
4685 struct sd *sd = (struct sd *) gspca_dev; in sd_dq_callback()
4696 reg_w(gspca_dev, 0x7d, 0x00); in sd_dq_callback()
4699 reg_w(gspca_dev, 0x27, 0xb0); in sd_dq_callback()
4702 reg_w(gspca_dev, 0x0c, 0x01); in sd_dq_callback()
4705 ret = usb_bulk_msg(gspca_dev->dev, in sd_dq_callback()
4706 usb_rcvbulkpipe(gspca_dev->dev, 0x02), in sd_dq_callback()
4707 gspca_dev->usb_buf, in sd_dq_callback()
4718 reg_w(gspca_dev, 0x27, 0xd0); in sd_dq_callback()
4721 ret = usb_bulk_msg(gspca_dev->dev, in sd_dq_callback()
4722 usb_rcvbulkpipe(gspca_dev->dev, 0x02), in sd_dq_callback()
4723 gspca_dev->usb_buf, in sd_dq_callback()
4731 luma = ((gspca_dev->usb_buf[8] << 8) + gspca_dev->usb_buf[7] + in sd_dq_callback()
4732 (gspca_dev->usb_buf[11] << 8) + gspca_dev->usb_buf[10] + in sd_dq_callback()
4733 (gspca_dev->usb_buf[14] << 8) + gspca_dev->usb_buf[13] + in sd_dq_callback()
4734 (gspca_dev->usb_buf[17] << 8) + gspca_dev->usb_buf[16] + in sd_dq_callback()
4735 (gspca_dev->usb_buf[20] << 8) + gspca_dev->usb_buf[19] + in sd_dq_callback()
4736 (gspca_dev->usb_buf[23] << 8) + gspca_dev->usb_buf[22] + in sd_dq_callback()
4737 (gspca_dev->usb_buf[26] << 8) + gspca_dev->usb_buf[25] + in sd_dq_callback()
4738 (gspca_dev->usb_buf[29] << 8) + gspca_dev->usb_buf[28]) in sd_dq_callback()
4740 if (gspca_dev->pixfmt.width == 640) in sd_dq_callback()
4742 reg_w(gspca_dev, 0x7d, 0x00); in sd_dq_callback()
4744 expo = v4l2_ctrl_g_ctrl(gspca_dev->exposure); in sd_dq_callback()
4745 ret = gspca_expo_autogain(gspca_dev, luma, in sd_dq_callback()
4752 int new_expo = v4l2_ctrl_g_ctrl(gspca_dev->exposure); in sd_dq_callback()
4756 setframerate(gspca_dev, new_expo); in sd_dq_callback()
4763 static void sd_get_streamparm(struct gspca_dev *gspca_dev, in sd_get_streamparm() argument
4766 struct sd *sd = (struct sd *) gspca_dev; in sd_get_streamparm()
4772 i = get_fr_idx(gspca_dev); in sd_get_streamparm()
4785 static void sd_set_streamparm(struct gspca_dev *gspca_dev, in sd_set_streamparm() argument
4788 struct sd *sd = (struct sd *) gspca_dev; in sd_set_streamparm()
4798 if (gspca_dev->streaming) in sd_set_streamparm()
4799 setframerate(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); in sd_set_streamparm()
4802 i = get_fr_idx(gspca_dev); in sd_set_streamparm()
4811 static int sd_set_jcomp(struct gspca_dev *gspca_dev, in sd_set_jcomp() argument
4814 struct sd *sd = (struct sd *) gspca_dev; in sd_set_jcomp()
4822 static int sd_get_jcomp(struct gspca_dev *gspca_dev, in sd_get_jcomp() argument
4825 struct sd *sd = (struct sd *) gspca_dev; in sd_get_jcomp()
4838 struct gspca_dev *gspca_dev = in sd_s_ctrl() local
4839 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
4840 struct sd *sd = (struct sd *)gspca_dev; in sd_s_ctrl()
4842 gspca_dev->usb_err = 0; in sd_s_ctrl()
4844 if (!gspca_dev->streaming) in sd_s_ctrl()
4849 setsharpness(gspca_dev, ctrl->val); in sd_s_ctrl()
4852 setgamma(gspca_dev, ctrl->val); in sd_s_ctrl()
4855 setbgain(gspca_dev, ctrl->val); in sd_s_ctrl()
4858 setrgain(gspca_dev, ctrl->val); in sd_s_ctrl()
4861 sd_setgain(gspca_dev); in sd_s_ctrl()
4866 sd_setgain(gspca_dev); in sd_s_ctrl()
4872 return gspca_dev->usb_err; in sd_s_ctrl()
4879 static int sd_init_controls(struct gspca_dev *gspca_dev) in sd_init_controls() argument
4881 struct sd *sd = (struct sd *)gspca_dev; in sd_init_controls()
4882 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
4884 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
4886 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4895 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4898 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4907 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4918 if (gspca_dev->autogain) in sd_init_controls()
4919 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); in sd_init_controls()
4921 v4l2_ctrl_cluster(2, &gspca_dev->exposure); in sd_init_controls()