Lines Matching refs:gspca_dev
123 struct gspca_dev gspca_dev; /* !! must be the first item */ member
987 static void reg_w(struct gspca_dev *gspca_dev, u8 index, u8 value) in reg_w() argument
989 struct usb_device *dev = gspca_dev->dev; in reg_w()
992 if (gspca_dev->usb_err < 0) in reg_w()
1000 gspca_dev->usb_err = ret; in reg_w()
1005 static void reg_r(struct gspca_dev *gspca_dev, u8 index) in reg_r() argument
1007 struct usb_device *dev = gspca_dev->dev; in reg_r()
1010 if (gspca_dev->usb_err < 0) in reg_r()
1015 0, index, gspca_dev->usb_buf, 1, 500); in reg_r()
1018 gspca_dev->usb_err = ret; in reg_r()
1022 static void reg_w_buf(struct gspca_dev *gspca_dev, in reg_w_buf() argument
1026 reg_w(gspca_dev, p->reg, p->val); in reg_w_buf()
1031 static int i2c_w(struct gspca_dev *gspca_dev, u8 index, u8 value) in i2c_w() argument
1033 struct sd *sd = (struct sd *) gspca_dev; in i2c_w()
1035 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x00); in i2c_w()
1036 reg_w(gspca_dev, TP6800_R19_SIF_ADDR_S2, index); in i2c_w()
1037 reg_w(gspca_dev, TP6800_R13_SIF_TX_DATA, value); in i2c_w()
1038 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x01); in i2c_w()
1042 reg_r(gspca_dev, TP6800_R11_SIF_CONTROL); in i2c_w()
1043 if (gspca_dev->usb_buf[0] == 0) in i2c_w()
1045 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x00); in i2c_w()
1049 static void i2c_w_buf(struct gspca_dev *gspca_dev, in i2c_w_buf() argument
1053 i2c_w(gspca_dev, p->reg, p->val); in i2c_w_buf()
1058 static int i2c_r(struct gspca_dev *gspca_dev, u8 index, int len) in i2c_r() argument
1060 struct sd *sd = (struct sd *) gspca_dev; in i2c_r()
1063 reg_w(gspca_dev, TP6800_R19_SIF_ADDR_S2, index); in i2c_r()
1064 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x02); in i2c_r()
1066 reg_r(gspca_dev, TP6800_R14_SIF_RX_DATA); in i2c_r()
1067 v = gspca_dev->usb_buf[0]; in i2c_r()
1071 reg_r(gspca_dev, TP6800_R1B_SIF_RX_DATA2); in i2c_r()
1072 v |= (gspca_dev->usb_buf[0] << 8); in i2c_r()
1074 reg_r(gspca_dev, TP6800_R11_SIF_CONTROL); in i2c_r()
1075 if (gspca_dev->usb_buf[0] == 0) in i2c_r()
1077 reg_w(gspca_dev, TP6800_R11_SIF_CONTROL, 0x00); in i2c_r()
1081 static void bulk_w(struct gspca_dev *gspca_dev, in bulk_w() argument
1086 struct usb_device *dev = gspca_dev->dev; in bulk_w()
1089 if (gspca_dev->usb_err < 0) in bulk_w()
1094 gspca_dev->usb_buf[0] = tag; in bulk_w()
1095 memcpy(&gspca_dev->usb_buf[1], data, count); in bulk_w()
1098 gspca_dev->usb_buf, count + 1, in bulk_w()
1103 gspca_dev->usb_err = ret; in bulk_w()
1113 static int probe_6810(struct gspca_dev *gspca_dev) in probe_6810() argument
1118 reg_r(gspca_dev, TP6800_R18_GPIO_DATA); in probe_6810()
1119 gpio = gspca_dev->usb_buf[0]; in probe_6810()
1120 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1121 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1122 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1123 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x04); /* i2c 16 bits */ in probe_6810()
1124 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x21); /* ov??? */ in probe_6810()
1125 reg_w(gspca_dev, TP6800_R1A_SIF_TX_DATA2, 0x00); in probe_6810()
1126 if (i2c_w(gspca_dev, 0x00, 0x00) >= 0) in probe_6810()
1129 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1130 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x00); /* i2c 8 bits */ in probe_6810()
1131 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x7f); /* (unknown i2c) */ in probe_6810()
1132 if (i2c_w(gspca_dev, 0x00, 0x00) >= 0) in probe_6810()
1135 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1136 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1137 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1138 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x00); /* i2c 8 bits */ in probe_6810()
1139 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x11); /* tas??? / hv??? */ in probe_6810()
1140 ret = i2c_r(gspca_dev, 0x00, 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_R12_SIF_ADDR_S, 0x6e); /* po??? */ in probe_6810()
1148 ret = i2c_r(gspca_dev, 0x00, 1); in probe_6810()
1152 ret = i2c_r(gspca_dev, 0x01, 1); in probe_6810()
1156 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1157 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1158 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1159 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x04); /* i2c 16 bits */ in probe_6810()
1160 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x5d); /* mi/mt??? */ in probe_6810()
1161 ret = i2c_r(gspca_dev, 0x00, 2); in probe_6810()
1165 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1166 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1167 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1168 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x5c); /* mi/mt??? */ in probe_6810()
1169 ret = i2c_r(gspca_dev, 0x36, 2); in probe_6810()
1173 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1174 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1175 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1176 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x61); /* (unknown i2c) */ in probe_6810()
1177 reg_w(gspca_dev, TP6800_R1A_SIF_TX_DATA2, 0x10); in probe_6810()
1178 if (i2c_w(gspca_dev, 0xff, 0x00) >= 0) in probe_6810()
1181 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1182 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio); in probe_6810()
1183 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, gpio | 0x20); in probe_6810()
1184 reg_w(gspca_dev, TP6800_R10_SIF_TYPE, 0x00); /* i2c 8 bits */ in probe_6810()
1185 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x20); /* cx0342 */ in probe_6810()
1186 ret = i2c_r(gspca_dev, 0x00, 1); in probe_6810()
1192 static void cx0342_6810_init(struct gspca_dev *gspca_dev) in cx0342_6810_init() argument
1244 reg_w_buf(gspca_dev, reg_init_1, ARRAY_SIZE(reg_init_1)); in cx0342_6810_init()
1245 reg_w_buf(gspca_dev, tp6810_cx_init_common, in cx0342_6810_init()
1247 reg_w_buf(gspca_dev, reg_init_2, ARRAY_SIZE(reg_init_2)); in cx0342_6810_init()
1249 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x20); /* cx0342 I2C addr */ in cx0342_6810_init()
1250 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in cx0342_6810_init()
1251 i2c_w_buf(gspca_dev, cx0342_timing_seq, ARRAY_SIZE(cx0342_timing_seq)); in cx0342_6810_init()
1254 static void soi763a_6810_init(struct gspca_dev *gspca_dev) in soi763a_6810_init() argument
1399 reg_w_buf(gspca_dev, reg_init_1, ARRAY_SIZE(reg_init_1)); in soi763a_6810_init()
1400 reg_w_buf(gspca_dev, tp6810_ov_init_common, in soi763a_6810_init()
1402 reg_w_buf(gspca_dev, reg_init_2, ARRAY_SIZE(reg_init_2)); in soi763a_6810_init()
1404 i2c_w(gspca_dev, 0x12, 0x80); /* sensor reset */ in soi763a_6810_init()
1406 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in soi763a_6810_init()
1410 static void setexposure(struct gspca_dev *gspca_dev, s32 expo, s32 gain, in setexposure() argument
1413 struct sd *sd = (struct sd *) gspca_dev; in setexposure()
1417 i2c_w(gspca_dev, CX0342_EXPO_LINE_L, expo); in setexposure()
1418 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, expo >> 8); in setexposure()
1420 i2c_w(gspca_dev, CX0342_RAW_GBGAIN_H, in setexposure()
1422 i2c_w(gspca_dev, CX0342_RAW_GBGAIN_L, gain); in setexposure()
1424 i2c_w(gspca_dev, CX0342_RAW_GRGAIN_H, in setexposure()
1426 i2c_w(gspca_dev, CX0342_RAW_GRGAIN_L, gain); in setexposure()
1429 i2c_w(gspca_dev, CX0342_RAW_BGAIN_H, in setexposure()
1431 i2c_w(gspca_dev, CX0342_RAW_BGAIN_L, blue); in setexposure()
1433 i2c_w(gspca_dev, CX0342_RAW_RGAIN_H, in setexposure()
1435 i2c_w(gspca_dev, CX0342_RAW_RGAIN_L, red); in setexposure()
1437 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, in setexposure()
1443 i2c_w(gspca_dev, 0x10, /* AEC_H (exposure time) */ in setexposure()
1446 i2c_w(gspca_dev, 0x00, /* gain */ in setexposure()
1451 static void set_dqt(struct gspca_dev *gspca_dev, u8 q) in set_dqt() argument
1453 struct sd *sd = (struct sd *) gspca_dev; in set_dqt()
1456 gspca_dbg(gspca_dev, D_STREAM, "q %d -> %d\n", sd->quality, q); in set_dqt()
1468 static void setquality(struct gspca_dev *gspca_dev, s32 q) in setquality() argument
1470 struct sd *sd = (struct sd *) gspca_dev; in setquality()
1475 reg_w(gspca_dev, TP6800_R7A_BLK_THRLD, 0x00); in setquality()
1476 reg_w(gspca_dev, TP6800_R79_QUALITY, 0x04); in setquality()
1477 reg_w(gspca_dev, TP6800_R79_QUALITY, q); in setquality()
1482 reg_w(gspca_dev, TP6800_R7A_BLK_THRLD, 0x19); in setquality()
1502 static void setgamma(struct gspca_dev *gspca_dev, s32 gamma) in setgamma() argument
1504 struct sd *sd = (struct sd *) gspca_dev; in setgamma()
3825 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); in setgamma()
3827 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3829 bulk_w(gspca_dev, 0x00, gamma_tb[gamma][0], 1024); in setgamma()
3830 bulk_w(gspca_dev, 0x01, gamma_tb[gamma][1], 1024); in setgamma()
3831 bulk_w(gspca_dev, 0x02, gamma_tb[gamma][2], 1024); in setgamma()
3835 reg_w(gspca_dev, 0x02, 0x2b); in setgamma()
3836 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3838 reg_w(gspca_dev, TP6800_R55_GAMMA_R, in setgamma()
3840 reg_w(gspca_dev, 0x02, 0x2b); in setgamma()
3841 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3843 reg_w(gspca_dev, TP6800_R56_GAMMA_G, in setgamma()
3845 reg_w(gspca_dev, 0x02, 0x2b); in setgamma()
3846 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3848 reg_w(gspca_dev, TP6800_R57_GAMMA_B, in setgamma()
3850 reg_w(gspca_dev, 0x02, 0x28); in setgamma()
3852 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x03); in setgamma()
3856 static void setsharpness(struct gspca_dev *gspca_dev, s32 val) in setsharpness() argument
3858 struct sd *sd = (struct sd *) gspca_dev; in setsharpness()
3862 if (gspca_dev->pixfmt.width == 640) in setsharpness()
3863 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in setsharpness()
3866 reg_w(gspca_dev, TP6800_R5D_DEMOSAIC_CFG, val); in setsharpness()
3869 reg_w(gspca_dev, 0x59, val); in setsharpness()
3873 static void setautogain(struct gspca_dev *gspca_dev, s32 val) in setautogain() argument
3875 struct sd *sd = (struct sd *) gspca_dev; in setautogain()
3881 static void set_resolution(struct gspca_dev *gspca_dev) in set_resolution() argument
3883 struct sd *sd = (struct sd *) gspca_dev; in set_resolution()
3885 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); in set_resolution()
3886 if (gspca_dev->pixfmt.width == 320) { in set_resolution()
3887 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x06); in set_resolution()
3889 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); in set_resolution()
3891 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x03); in set_resolution()
3892 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x01); /* qvga */ in set_resolution()
3893 reg_w(gspca_dev, TP6800_R5D_DEMOSAIC_CFG, 0x0d); in set_resolution()
3894 i2c_w(gspca_dev, CX0342_EXPO_LINE_L, 0x37); in set_resolution()
3895 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, 0x01); in set_resolution()
3897 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x05); in set_resolution()
3899 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); in set_resolution()
3901 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x03); in set_resolution()
3902 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in set_resolution()
3903 reg_w(gspca_dev, TP6800_R5D_DEMOSAIC_CFG, 0x09); in set_resolution()
3904 i2c_w(gspca_dev, CX0342_EXPO_LINE_L, 0xcf); in set_resolution()
3905 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, 0x00); in set_resolution()
3907 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x01); in set_resolution()
3908 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_CX0342], in set_resolution()
3910 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in set_resolution()
3912 setquality(gspca_dev, v4l2_ctrl_g_ctrl(sd->jpegqual)); in set_resolution()
3916 static int get_fr_idx(struct gspca_dev *gspca_dev) in get_fr_idx() argument
3918 struct sd *sd = (struct sd *) gspca_dev; in get_fr_idx()
3930 && gspca_dev->pixfmt.width == 640) in get_fr_idx()
3941 && gspca_dev->pixfmt.width == 640) in get_fr_idx()
3948 static void setframerate(struct gspca_dev *gspca_dev, s32 val) in setframerate() argument
3950 struct sd *sd = (struct sd *) gspca_dev; in setframerate()
3953 fr_idx = get_fr_idx(gspca_dev); in setframerate()
3956 reg_r(gspca_dev, 0x7b); in setframerate()
3957 reg_w(gspca_dev, 0x7b, in setframerate()
3963 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, fr_idx); in setframerate()
3966 i2c_w(gspca_dev, CX0342_AUTO_ADC_CALIB, 0x01); in setframerate()
3969 static void setrgain(struct gspca_dev *gspca_dev, s32 rgain) in setrgain() argument
3971 i2c_w(gspca_dev, CX0342_RAW_RGAIN_H, rgain >> 8); in setrgain()
3972 i2c_w(gspca_dev, CX0342_RAW_RGAIN_L, rgain); in setrgain()
3973 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x80); in setrgain()
3976 static int sd_setgain(struct gspca_dev *gspca_dev) in sd_setgain() argument
3978 struct sd *sd = (struct sd *) gspca_dev; in sd_setgain()
3979 s32 val = gspca_dev->gain->val; in sd_setgain()
3982 s32 old = gspca_dev->gain->cur.val ? in sd_setgain()
3983 gspca_dev->gain->cur.val : 1; in sd_setgain()
3992 if (gspca_dev->streaming) { in sd_setgain()
3994 setexposure(gspca_dev, gspca_dev->exposure->val, in sd_setgain()
3995 gspca_dev->gain->val, in sd_setgain()
3998 setexposure(gspca_dev, gspca_dev->exposure->val, in sd_setgain()
3999 gspca_dev->gain->val, 0, 0); in sd_setgain()
4001 return gspca_dev->usb_err; in sd_setgain()
4004 static void setbgain(struct gspca_dev *gspca_dev, s32 bgain) in setbgain() argument
4006 i2c_w(gspca_dev, CX0342_RAW_BGAIN_H, bgain >> 8); in setbgain()
4007 i2c_w(gspca_dev, CX0342_RAW_BGAIN_L, bgain); in setbgain()
4008 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x80); in setbgain()
4012 static int sd_config(struct gspca_dev *gspca_dev, in sd_config() argument
4015 struct sd *sd = (struct sd *) gspca_dev; in sd_config()
4019 gspca_dev->cam.cam_mode = vga_mode; in sd_config()
4020 gspca_dev->cam.nmodes = ARRAY_SIZE(vga_mode); in sd_config()
4021 gspca_dev->cam.mode_framerates = sd->bridge == BRIDGE_TP6800 ? in sd_config()
4029 static int sd_init(struct gspca_dev *gspca_dev) in sd_init() argument
4031 struct sd *sd = (struct sd *) gspca_dev; in sd_init()
4049 reg_w_buf(gspca_dev, tp6800_preinit, in sd_init()
4052 reg_w_buf(gspca_dev, tp6810_preinit, in sd_init()
4055 reg_r(gspca_dev, TP6800_R18_GPIO_DATA); in sd_init()
4056 gspca_dbg(gspca_dev, D_PROBE, "gpio: %02x\n", gspca_dev->usb_buf[0]); in sd_init()
4070 switch (gspca_dev->usb_buf[0] & 0x07) { in sd_init()
4081 sensor = probe_6810(gspca_dev); in sd_init()
4093 soi763a_6810_init(gspca_dev); in sd_init()
4098 cx0342_6810_init(gspca_dev); in sd_init()
4102 set_dqt(gspca_dev, 0); in sd_init()
4107 static int sd_isoc_init(struct gspca_dev *gspca_dev) in sd_isoc_init() argument
4109 struct sd *sd = (struct sd *) gspca_dev; in sd_isoc_init()
4139 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x20); in sd_isoc_init()
4140 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x87); in sd_isoc_init()
4141 i2c_w_buf(gspca_dev, cx_sensor_init, in sd_isoc_init()
4143 reg_w_buf(gspca_dev, cx_bridge_init, in sd_isoc_init()
4145 bulk_w(gspca_dev, 0x03, color_null, sizeof color_null); in sd_isoc_init()
4146 reg_w(gspca_dev, 0x59, 0x40); in sd_isoc_init()
4148 reg_w(gspca_dev, TP6800_R12_SIF_ADDR_S, 0x21); in sd_isoc_init()
4149 i2c_w_buf(gspca_dev, ov_sensor_init, in sd_isoc_init()
4151 reg_r(gspca_dev, 0x7b); in sd_isoc_init()
4152 reg_w_buf(gspca_dev, ov_bridge_init, in sd_isoc_init()
4155 reg_w(gspca_dev, TP6800_R78_FORMAT, in sd_isoc_init()
4156 gspca_dev->curr_mode ? 0x00 : 0x01); in sd_isoc_init()
4157 return gspca_dev->usb_err; in sd_isoc_init()
4160 static void set_led(struct gspca_dev *gspca_dev, int on) in set_led() argument
4164 reg_r(gspca_dev, TP6800_R18_GPIO_DATA); in set_led()
4165 data = gspca_dev->usb_buf[0]; in set_led()
4170 reg_w(gspca_dev, TP6800_R18_GPIO_DATA, data); in set_led()
4173 static void cx0342_6800_start(struct gspca_dev *gspca_dev) in cx0342_6800_start() argument
4175 struct sd *sd = (struct sd *) gspca_dev; in cx0342_6800_start()
4241 reg_w_buf(gspca_dev, reg_init, ARRAY_SIZE(reg_init)); in cx0342_6800_start()
4242 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in cx0342_6800_start()
4243 i2c_w_buf(gspca_dev, cx0342_timing_seq, ARRAY_SIZE(cx0342_timing_seq)); in cx0342_6800_start()
4244 reg_w(gspca_dev, TP6800_R5C_EDGE_THRLD, 0x10); in cx0342_6800_start()
4245 reg_w(gspca_dev, TP6800_R54_DARK_CFG, 0x00); in cx0342_6800_start()
4246 i2c_w(gspca_dev, CX0342_EXPO_LINE_H, 0x00); in cx0342_6800_start()
4247 i2c_w(gspca_dev, CX0342_SYS_CTRL_0, 0x01); in cx0342_6800_start()
4249 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in cx0342_6800_start()
4250 v4l2_ctrl_g_ctrl(gspca_dev->gain), in cx0342_6800_start()
4254 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in cx0342_6800_start()
4255 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in cx0342_6800_start()
4256 set_led(gspca_dev, 1); in cx0342_6800_start()
4257 set_resolution(gspca_dev); in cx0342_6800_start()
4260 static void cx0342_6810_start(struct gspca_dev *gspca_dev) in cx0342_6810_start() argument
4262 struct sd *sd = (struct sd *) gspca_dev; in cx0342_6810_start()
4328 reg_w(gspca_dev, 0x22, gspca_dev->alt); in cx0342_6810_start()
4329 i2c_w_buf(gspca_dev, sensor_init_2, ARRAY_SIZE(sensor_init_2)); in cx0342_6810_start()
4330 reg_w_buf(gspca_dev, bridge_init_2, ARRAY_SIZE(bridge_init_2)); in cx0342_6810_start()
4331 reg_w_buf(gspca_dev, tp6810_cx_init_common, in cx0342_6810_start()
4333 reg_w_buf(gspca_dev, bridge_init_3, ARRAY_SIZE(bridge_init_3)); in cx0342_6810_start()
4334 if (gspca_dev->curr_mode) { in cx0342_6810_start()
4335 reg_w(gspca_dev, 0x4a, 0x7f); in cx0342_6810_start()
4336 reg_w(gspca_dev, 0x07, 0x05); in cx0342_6810_start()
4337 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in cx0342_6810_start()
4339 reg_w(gspca_dev, 0x4a, 0xff); in cx0342_6810_start()
4340 reg_w(gspca_dev, 0x07, 0x85); in cx0342_6810_start()
4341 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x01); /* qvga */ in cx0342_6810_start()
4343 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in cx0342_6810_start()
4344 reg_w_buf(gspca_dev, tp6810_bridge_start, in cx0342_6810_start()
4346 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in cx0342_6810_start()
4347 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_CX0342], in cx0342_6810_start()
4349 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0x87); in cx0342_6810_start()
4350 i2c_w_buf(gspca_dev, sensor_init_3, ARRAY_SIZE(sensor_init_3)); in cx0342_6810_start()
4351 reg_w_buf(gspca_dev, bridge_init_5, ARRAY_SIZE(bridge_init_5)); in cx0342_6810_start()
4352 i2c_w_buf(gspca_dev, sensor_init_4, ARRAY_SIZE(sensor_init_4)); in cx0342_6810_start()
4353 reg_w_buf(gspca_dev, bridge_init_5, ARRAY_SIZE(bridge_init_5)); in cx0342_6810_start()
4354 i2c_w_buf(gspca_dev, sensor_init_5, ARRAY_SIZE(sensor_init_5)); in cx0342_6810_start()
4356 set_led(gspca_dev, 1); in cx0342_6810_start()
4360 static void soi763a_6800_start(struct gspca_dev *gspca_dev) in soi763a_6800_start() argument
4362 struct sd *sd = (struct sd *) gspca_dev; in soi763a_6800_start()
4452 reg_w_buf(gspca_dev, reg_init, ARRAY_SIZE(reg_init)); in soi763a_6800_start()
4454 i2c_w(gspca_dev, 0x12, 0x80); /* sensor reset */ in soi763a_6800_start()
4457 i2c_w_buf(gspca_dev, sensor_init, ARRAY_SIZE(sensor_init)); in soi763a_6800_start()
4459 reg_w(gspca_dev, TP6800_R5C_EDGE_THRLD, 0x10); in soi763a_6800_start()
4460 reg_w(gspca_dev, TP6800_R54_DARK_CFG, 0x00); in soi763a_6800_start()
4462 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in soi763a_6800_start()
4464 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_SOI763A], in soi763a_6800_start()
4467 set_led(gspca_dev, 1); in soi763a_6800_start()
4469 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6800_start()
4470 v4l2_ctrl_g_ctrl(gspca_dev->gain), in soi763a_6800_start()
4474 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6800_start()
4475 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in soi763a_6800_start()
4477 setquality(gspca_dev, v4l2_ctrl_g_ctrl(sd->jpegqual)); in soi763a_6800_start()
4478 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in soi763a_6800_start()
4481 static void soi763a_6810_start(struct gspca_dev *gspca_dev) in soi763a_6810_start() argument
4483 struct sd *sd = (struct sd *) gspca_dev; in soi763a_6810_start()
4504 reg_w(gspca_dev, 0x22, gspca_dev->alt); in soi763a_6810_start()
4505 bulk_w(gspca_dev, 0x03, color_null, sizeof color_null); in soi763a_6810_start()
4506 reg_w(gspca_dev, 0x59, 0x40); in soi763a_6810_start()
4508 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4509 v4l2_ctrl_g_ctrl(gspca_dev->gain), in soi763a_6810_start()
4513 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4514 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in soi763a_6810_start()
4515 reg_w_buf(gspca_dev, bridge_init_2, ARRAY_SIZE(bridge_init_2)); in soi763a_6810_start()
4516 reg_w_buf(gspca_dev, tp6810_ov_init_common, in soi763a_6810_start()
4518 reg_w_buf(gspca_dev, bridge_init_3, ARRAY_SIZE(bridge_init_3)); in soi763a_6810_start()
4519 if (gspca_dev->curr_mode) { in soi763a_6810_start()
4520 reg_w(gspca_dev, 0x4a, 0x7f); in soi763a_6810_start()
4521 reg_w(gspca_dev, 0x07, 0x05); in soi763a_6810_start()
4522 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x00); /* vga */ in soi763a_6810_start()
4524 reg_w(gspca_dev, 0x4a, 0xff); in soi763a_6810_start()
4525 reg_w(gspca_dev, 0x07, 0x85); in soi763a_6810_start()
4526 reg_w(gspca_dev, TP6800_R78_FORMAT, 0x01); /* qvga */ in soi763a_6810_start()
4528 setgamma(gspca_dev, v4l2_ctrl_g_ctrl(sd->gamma)); in soi763a_6810_start()
4529 reg_w_buf(gspca_dev, tp6810_bridge_start, in soi763a_6810_start()
4532 if (gspca_dev->curr_mode) { in soi763a_6810_start()
4533 reg_w(gspca_dev, 0x4f, 0x00); in soi763a_6810_start()
4534 reg_w(gspca_dev, 0x4e, 0x7c); in soi763a_6810_start()
4537 reg_w(gspca_dev, 0x00, 0x00); in soi763a_6810_start()
4539 setsharpness(gspca_dev, v4l2_ctrl_g_ctrl(sd->sharpness)); in soi763a_6810_start()
4540 bulk_w(gspca_dev, 0x03, color_gain[SENSOR_SOI763A], in soi763a_6810_start()
4542 set_led(gspca_dev, 1); in soi763a_6810_start()
4543 reg_w(gspca_dev, TP6800_R3F_FRAME_RATE, 0xf0); in soi763a_6810_start()
4545 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4546 v4l2_ctrl_g_ctrl(gspca_dev->gain), in soi763a_6810_start()
4550 setexposure(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure), in soi763a_6810_start()
4551 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in soi763a_6810_start()
4552 reg_w_buf(gspca_dev, bridge_init_6, ARRAY_SIZE(bridge_init_6)); in soi763a_6810_start()
4556 static int sd_start(struct gspca_dev *gspca_dev) in sd_start() argument
4558 struct sd *sd = (struct sd *) gspca_dev; in sd_start()
4560 jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height, in sd_start()
4561 gspca_dev->pixfmt.width); in sd_start()
4562 set_dqt(gspca_dev, sd->quality); in sd_start()
4565 cx0342_6800_start(gspca_dev); in sd_start()
4567 soi763a_6800_start(gspca_dev); in sd_start()
4570 cx0342_6810_start(gspca_dev); in sd_start()
4572 soi763a_6810_start(gspca_dev); in sd_start()
4573 reg_w_buf(gspca_dev, tp6810_late_start, in sd_start()
4575 reg_w(gspca_dev, 0x80, 0x03); in sd_start()
4576 reg_w(gspca_dev, 0x82, gspca_dev->curr_mode ? 0x0a : 0x0e); in sd_start()
4579 setexposure(gspca_dev, in sd_start()
4580 v4l2_ctrl_g_ctrl(gspca_dev->exposure), in sd_start()
4581 v4l2_ctrl_g_ctrl(gspca_dev->gain), in sd_start()
4585 setexposure(gspca_dev, in sd_start()
4586 v4l2_ctrl_g_ctrl(gspca_dev->exposure), in sd_start()
4587 v4l2_ctrl_g_ctrl(gspca_dev->gain), 0, 0); in sd_start()
4589 setquality(gspca_dev, in sd_start()
4592 setautogain(gspca_dev, in sd_start()
4593 v4l2_ctrl_g_ctrl(gspca_dev->autogain)); in sd_start()
4596 setframerate(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); in sd_start()
4598 return gspca_dev->usb_err; in sd_start()
4601 static void sd_stopN(struct gspca_dev *gspca_dev) in sd_stopN() argument
4603 struct sd *sd = (struct sd *) gspca_dev; in sd_stopN()
4606 reg_w(gspca_dev, TP6800_R2F_TIMING_CFG, 0x03); in sd_stopN()
4607 set_led(gspca_dev, 0); in sd_stopN()
4608 reg_w(gspca_dev, TP6800_R21_ENDP_1_CTL, 0x00); in sd_stopN()
4611 static void sd_pkt_scan(struct gspca_dev *gspca_dev, in sd_pkt_scan() argument
4615 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan()
4630 gspca_dbg(gspca_dev, D_FRAM, "bad frame\n"); in sd_pkt_scan()
4631 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4638 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4644 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4648 set_dqt(gspca_dev, data[6] & 0x0f); in sd_pkt_scan()
4649 gspca_frame_add(gspca_dev, FIRST_PACKET, in sd_pkt_scan()
4651 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4654 gspca_frame_add(gspca_dev, LAST_PACKET, in sd_pkt_scan()
4657 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4665 gspca_frame_add(gspca_dev, LAST_PACKET, data, 0); in sd_pkt_scan()
4672 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4676 set_dqt(gspca_dev, data[7]); in sd_pkt_scan()
4677 gspca_frame_add(gspca_dev, FIRST_PACKET, in sd_pkt_scan()
4679 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4683 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4687 gspca_frame_add(gspca_dev, INTER_PACKET, in sd_pkt_scan()
4690 gspca_dev->last_packet_type = DISCARD_PACKET; in sd_pkt_scan()
4695 static void sd_dq_callback(struct gspca_dev *gspca_dev) in sd_dq_callback() argument
4697 struct sd *sd = (struct sd *) gspca_dev; in sd_dq_callback()
4708 reg_w(gspca_dev, 0x7d, 0x00); in sd_dq_callback()
4711 reg_w(gspca_dev, 0x27, 0xb0); in sd_dq_callback()
4714 reg_w(gspca_dev, 0x0c, 0x01); in sd_dq_callback()
4717 ret = usb_bulk_msg(gspca_dev->dev, in sd_dq_callback()
4718 usb_rcvbulkpipe(gspca_dev->dev, 0x02), in sd_dq_callback()
4719 gspca_dev->usb_buf, in sd_dq_callback()
4730 reg_w(gspca_dev, 0x27, 0xd0); in sd_dq_callback()
4733 ret = usb_bulk_msg(gspca_dev->dev, in sd_dq_callback()
4734 usb_rcvbulkpipe(gspca_dev->dev, 0x02), in sd_dq_callback()
4735 gspca_dev->usb_buf, in sd_dq_callback()
4743 luma = ((gspca_dev->usb_buf[8] << 8) + gspca_dev->usb_buf[7] + in sd_dq_callback()
4744 (gspca_dev->usb_buf[11] << 8) + gspca_dev->usb_buf[10] + in sd_dq_callback()
4745 (gspca_dev->usb_buf[14] << 8) + gspca_dev->usb_buf[13] + in sd_dq_callback()
4746 (gspca_dev->usb_buf[17] << 8) + gspca_dev->usb_buf[16] + in sd_dq_callback()
4747 (gspca_dev->usb_buf[20] << 8) + gspca_dev->usb_buf[19] + in sd_dq_callback()
4748 (gspca_dev->usb_buf[23] << 8) + gspca_dev->usb_buf[22] + in sd_dq_callback()
4749 (gspca_dev->usb_buf[26] << 8) + gspca_dev->usb_buf[25] + in sd_dq_callback()
4750 (gspca_dev->usb_buf[29] << 8) + gspca_dev->usb_buf[28]) in sd_dq_callback()
4752 if (gspca_dev->pixfmt.width == 640) in sd_dq_callback()
4754 reg_w(gspca_dev, 0x7d, 0x00); in sd_dq_callback()
4756 expo = v4l2_ctrl_g_ctrl(gspca_dev->exposure); in sd_dq_callback()
4757 ret = gspca_expo_autogain(gspca_dev, luma, in sd_dq_callback()
4764 int new_expo = v4l2_ctrl_g_ctrl(gspca_dev->exposure); in sd_dq_callback()
4768 setframerate(gspca_dev, new_expo); in sd_dq_callback()
4775 static void sd_get_streamparm(struct gspca_dev *gspca_dev, in sd_get_streamparm() argument
4778 struct sd *sd = (struct sd *) gspca_dev; in sd_get_streamparm()
4784 i = get_fr_idx(gspca_dev); in sd_get_streamparm()
4797 static void sd_set_streamparm(struct gspca_dev *gspca_dev, in sd_set_streamparm() argument
4800 struct sd *sd = (struct sd *) gspca_dev; in sd_set_streamparm()
4810 if (gspca_dev->streaming) in sd_set_streamparm()
4811 setframerate(gspca_dev, v4l2_ctrl_g_ctrl(gspca_dev->exposure)); in sd_set_streamparm()
4814 i = get_fr_idx(gspca_dev); in sd_set_streamparm()
4823 static int sd_set_jcomp(struct gspca_dev *gspca_dev, in sd_set_jcomp() argument
4826 struct sd *sd = (struct sd *) gspca_dev; in sd_set_jcomp()
4834 static int sd_get_jcomp(struct gspca_dev *gspca_dev, in sd_get_jcomp() argument
4837 struct sd *sd = (struct sd *) gspca_dev; in sd_get_jcomp()
4850 struct gspca_dev *gspca_dev = in sd_s_ctrl() local
4851 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
4852 struct sd *sd = (struct sd *)gspca_dev; in sd_s_ctrl()
4854 gspca_dev->usb_err = 0; in sd_s_ctrl()
4856 if (!gspca_dev->streaming) in sd_s_ctrl()
4861 setsharpness(gspca_dev, ctrl->val); in sd_s_ctrl()
4864 setgamma(gspca_dev, ctrl->val); in sd_s_ctrl()
4867 setbgain(gspca_dev, ctrl->val); in sd_s_ctrl()
4870 setrgain(gspca_dev, ctrl->val); in sd_s_ctrl()
4873 sd_setgain(gspca_dev); in sd_s_ctrl()
4878 sd_setgain(gspca_dev); in sd_s_ctrl()
4884 return gspca_dev->usb_err; in sd_s_ctrl()
4891 static int sd_init_controls(struct gspca_dev *gspca_dev) in sd_init_controls() argument
4893 struct sd *sd = (struct sd *)gspca_dev; in sd_init_controls()
4894 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
4896 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
4898 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4907 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4910 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4919 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4930 if (gspca_dev->autogain) in sd_init_controls()
4931 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); in sd_init_controls()
4933 v4l2_ctrl_cluster(2, &gspca_dev->exposure); in sd_init_controls()