Lines Matching refs:gspca_dev
31 struct gspca_dev gspca_dev; /* !! must be the first item */ member
2899 static void reg_r_i(struct gspca_dev *gspca_dev, in reg_r_i() argument
2906 if (gspca_dev->usb_err < 0) in reg_r_i()
2908 ret = usb_control_msg(gspca_dev->dev, in reg_r_i()
2909 usb_rcvctrlpipe(gspca_dev->dev, 0), in reg_r_i()
2913 index, gspca_dev->usb_buf, len, in reg_r_i()
2917 gspca_dev->usb_err = ret; in reg_r_i()
2922 memset(gspca_dev->usb_buf, 0, USB_BUF_SZ); in reg_r_i()
2925 static void reg_r(struct gspca_dev *gspca_dev, in reg_r() argument
2930 reg_r_i(gspca_dev, req, index, len); in reg_r()
2931 if (gspca_dev->usb_err < 0) in reg_r()
2934 gspca_dbg(gspca_dev, D_USBI, "GET %02x 0001 %04x %02x\n", in reg_r()
2936 gspca_dev->usb_buf[0]); in reg_r()
2938 gspca_dbg(gspca_dev, D_USBI, "GET %02x 0001 %04x %*ph\n", in reg_r()
2939 req, index, 3, gspca_dev->usb_buf); in reg_r()
2942 static void reg_w_i(struct gspca_dev *gspca_dev, in reg_w_i() argument
2949 if (gspca_dev->usb_err < 0) in reg_w_i()
2951 ret = usb_control_msg(gspca_dev->dev, in reg_w_i()
2952 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w_i()
2959 gspca_dev->usb_err = ret; in reg_w_i()
2962 static void reg_w(struct gspca_dev *gspca_dev, in reg_w() argument
2967 if (gspca_dev->usb_err < 0) in reg_w()
2969 gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x\n", req, value, index); in reg_w()
2970 reg_w_i(gspca_dev, req, value, index); in reg_w()
2973 static u16 read_sensor_register(struct gspca_dev *gspca_dev, in read_sensor_register() argument
2979 reg_r(gspca_dev, 0xa1, 0xb33f, 1); in read_sensor_register()
2980 if (!(gspca_dev->usb_buf[0] & 0x02)) { in read_sensor_register()
2981 pr_err("I2c Bus Busy Wait %02x\n", gspca_dev->usb_buf[0]); in read_sensor_register()
2984 reg_w(gspca_dev, 0xa0, address, 0xb33a); in read_sensor_register()
2985 reg_w(gspca_dev, 0xa0, 0x02, 0xb339); in read_sensor_register()
2988 reg_r(gspca_dev, 0xa1, 0xb33b, 1); in read_sensor_register()
2989 if (gspca_dev->usb_buf[0] == 0x00) in read_sensor_register()
2994 reg_r(gspca_dev, 0xa1, 0xb33e, 1); in read_sensor_register()
2995 ldata = gspca_dev->usb_buf[0]; in read_sensor_register()
2996 reg_r(gspca_dev, 0xa1, 0xb33d, 1); in read_sensor_register()
2997 mdata = gspca_dev->usb_buf[0]; in read_sensor_register()
2998 reg_r(gspca_dev, 0xa1, 0xb33c, 1); in read_sensor_register()
2999 hdata = gspca_dev->usb_buf[0]; in read_sensor_register()
3001 gspca_dbg(gspca_dev, D_PROBE, "Read Sensor %02x%02x %02x\n", in read_sensor_register()
3003 reg_r(gspca_dev, 0xa1, 0xb334, 1); in read_sensor_register()
3004 if (gspca_dev->usb_buf[0] == 0x02) in read_sensor_register()
3009 static int vc032x_probe_sensor(struct gspca_dev *gspca_dev) in vc032x_probe_sensor() argument
3011 struct sd *sd = (struct sd *) gspca_dev; in vc032x_probe_sensor()
3018 reg_w(gspca_dev, 0xa0, 0x01, 0xb301); in vc032x_probe_sensor()
3019 reg_w(gspca_dev, 0x89, 0xf0ff, 0xffff); in vc032x_probe_sensor()
3023 reg_r(gspca_dev, 0xa1, 0xbfcf, 1); in vc032x_probe_sensor()
3024 gspca_dbg(gspca_dev, D_PROBE, "vc032%d check sensor header %02x\n", in vc032x_probe_sensor()
3025 sd->bridge == BRIDGE_VC0321 ? 1 : 3, gspca_dev->usb_buf[0]); in vc032x_probe_sensor()
3034 reg_w(gspca_dev, 0xa0, 0x02, 0xb334); in vc032x_probe_sensor()
3035 reg_w(gspca_dev, 0xa0, ptsensor_info->m1, 0xb300); in vc032x_probe_sensor()
3036 reg_w(gspca_dev, 0xa0, ptsensor_info->m2, 0xb300); in vc032x_probe_sensor()
3037 reg_w(gspca_dev, 0xa0, 0x01, 0xb308); in vc032x_probe_sensor()
3038 reg_w(gspca_dev, 0xa0, 0x0c, 0xb309); in vc032x_probe_sensor()
3039 reg_w(gspca_dev, 0xa0, ptsensor_info->I2cAdd, 0xb335); in vc032x_probe_sensor()
3040 reg_w(gspca_dev, 0xa0, ptsensor_info->op, 0xb301); in vc032x_probe_sensor()
3041 value = read_sensor_register(gspca_dev, ptsensor_info->IdAdd); in vc032x_probe_sensor()
3043 value = read_sensor_register(gspca_dev, 0x83); in vc032x_probe_sensor()
3045 gspca_dbg(gspca_dev, D_PROBE, "Sensor ID %04x (%d)\n", in vc032x_probe_sensor()
3064 static void i2c_write(struct gspca_dev *gspca_dev, in i2c_write() argument
3070 if (gspca_dev->usb_err < 0) in i2c_write()
3073 gspca_dbg(gspca_dev, D_USBO, "i2c_w %02x %02x\n", reg, *val); in i2c_write()
3075 gspca_dbg(gspca_dev, D_USBO, "i2c_w %02x %02x%02x\n", in i2c_write()
3077 reg_r_i(gspca_dev, 0xa1, 0xb33f, 1); in i2c_write()
3079 reg_w_i(gspca_dev, 0xa0, size, 0xb334); in i2c_write()
3080 reg_w_i(gspca_dev, 0xa0, reg, 0xb33a); in i2c_write()
3081 reg_w_i(gspca_dev, 0xa0, val[0], 0xb336); in i2c_write()
3083 reg_w_i(gspca_dev, 0xa0, val[1], 0xb337); in i2c_write()
3084 reg_w_i(gspca_dev, 0xa0, 0x01, 0xb339); in i2c_write()
3087 reg_r_i(gspca_dev, 0xa1, 0xb33b, 1); in i2c_write()
3088 if (gspca_dev->usb_buf[0] == 0) in i2c_write()
3096 static void put_tab_to_reg(struct gspca_dev *gspca_dev, in put_tab_to_reg() argument
3103 reg_w(gspca_dev, 0xa0, tab[j], ad++); in put_tab_to_reg()
3106 static void usb_exchange(struct gspca_dev *gspca_dev, in usb_exchange() argument
3116 reg_w(gspca_dev, 0xa0, data[i][2], in usb_exchange()
3120 i2c_write(gspca_dev, data[i][1], &data[i][2], 1); in usb_exchange()
3123 i2c_write(gspca_dev, data[i][0], &data[i][1], 2); in usb_exchange()
3136 static int sd_config(struct gspca_dev *gspca_dev, in sd_config() argument
3139 struct sd *sd = (struct sd *) gspca_dev; in sd_config()
3152 static int sd_init(struct gspca_dev *gspca_dev) in sd_init() argument
3154 struct sd *sd = (struct sd *) gspca_dev; in sd_init()
3172 sensor = vc032x_probe_sensor(gspca_dev); in sd_init()
3181 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor HV7131R\n"); in sd_init()
3184 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI0360\n"); in sd_init()
3188 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI1310_SOC\n"); in sd_init()
3191 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI1320\n"); in sd_init()
3194 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor MI1320_SOC\n"); in sd_init()
3197 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7660\n"); in sd_init()
3200 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor OV7670\n"); in sd_init()
3203 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PO1200\n"); in sd_init()
3206 gspca_dbg(gspca_dev, D_PROBE, "Find Sensor PO3130NC\n"); in sd_init()
3209 gspca_dbg(gspca_dev, D_PROBE, "Sensor POxxxx\n"); in sd_init()
3214 cam = &gspca_dev->cam; in sd_init()
3248 reg_r(gspca_dev, 0x8a, 0, 3); in sd_init()
3249 reg_w(gspca_dev, 0x87, 0x00, 0x0f0f); in sd_init()
3250 reg_r(gspca_dev, 0x8b, 0, 3); in sd_init()
3251 reg_w(gspca_dev, 0x88, 0x00, 0x0202); in sd_init()
3253 reg_r(gspca_dev, 0xa1, 0xb300, 1); in sd_init()
3254 if (gspca_dev->usb_buf[0] != 0) { in sd_init()
3255 reg_w(gspca_dev, 0xa0, 0x26, 0xb300); in sd_init()
3256 reg_w(gspca_dev, 0xa0, 0x04, 0xb300); in sd_init()
3258 reg_w(gspca_dev, 0xa0, 0x00, 0xb300); in sd_init()
3261 return gspca_dev->usb_err; in sd_init()
3264 static void setbrightness(struct gspca_dev *gspca_dev, s32 val) in setbrightness() argument
3273 i2c_write(gspca_dev, 0x98, &data, 1); in setbrightness()
3276 static void setcontrast(struct gspca_dev *gspca_dev, u8 val) in setcontrast() argument
3278 i2c_write(gspca_dev, 0x99, &val, 1); in setcontrast()
3281 static void setcolors(struct gspca_dev *gspca_dev, u8 val) in setcolors() argument
3286 i2c_write(gspca_dev, 0x94, &data, 1); in setcolors()
3287 i2c_write(gspca_dev, 0x95, &val, 1); in setcolors()
3290 static void sethvflip(struct gspca_dev *gspca_dev, bool hflip, bool vflip) in sethvflip() argument
3292 struct sd *sd = (struct sd *) gspca_dev; in sethvflip()
3304 i2c_write(gspca_dev, 0xf0, data, 2); in sethvflip()
3308 i2c_write(gspca_dev, 0x20, data, 2); in sethvflip()
3315 i2c_write(gspca_dev, OV7660_REG_MVFP, data, 1); in sethvflip()
3319 i2c_write(gspca_dev, 0x03, data, 1); in sethvflip()
3323 i2c_write(gspca_dev, 0x1e, data, 1); in sethvflip()
3328 static void setlightfreq(struct gspca_dev *gspca_dev, s32 val) in setlightfreq() argument
3330 struct sd *sd = (struct sd *) gspca_dev; in setlightfreq()
3336 usb_exchange(gspca_dev, ov7660_freq_tb[val]); in setlightfreq()
3339 static void setsharpness(struct gspca_dev *gspca_dev, s32 val) in setsharpness() argument
3341 struct sd *sd = (struct sd *) gspca_dev; in setsharpness()
3347 i2c_write(gspca_dev, 0x03, &data, 1); in setsharpness()
3352 i2c_write(gspca_dev, 0x61, &data, 1); in setsharpness()
3359 i2c_write(gspca_dev, 0x59, &data, 1); in setsharpness()
3363 static void setgain(struct gspca_dev *gspca_dev, u8 val) in setgain() argument
3365 i2c_write(gspca_dev, 0x15, &val, 1); in setgain()
3368 static void setexposure(struct gspca_dev *gspca_dev, s32 val) in setexposure() argument
3373 i2c_write(gspca_dev, 0x1a, &data, 1); in setexposure()
3375 i2c_write(gspca_dev, 0x1b, &data, 1); in setexposure()
3378 static void setautogain(struct gspca_dev *gspca_dev, s32 val) in setautogain() argument
3382 i2c_write(gspca_dev, 0xd1, &data[val], 1); in setautogain()
3385 static void setgamma(struct gspca_dev *gspca_dev) in setgamma() argument
3388 usb_exchange(gspca_dev, poxxxx_gamma); in setgamma()
3391 static void setbacklight(struct gspca_dev *gspca_dev, s32 val) in setbacklight() argument
3397 i2c_write(gspca_dev, 0xaa, &data, 1); in setbacklight()
3400 i2c_write(gspca_dev, 0xc4, &data, 1); in setbacklight()
3402 i2c_write(gspca_dev, 0xc5, &data, 1); in setbacklight()
3405 i2c_write(gspca_dev, 0xc6, &data, 1); in setbacklight()
3407 i2c_write(gspca_dev, 0xc7, &data, 1); in setbacklight()
3410 i2c_write(gspca_dev, 0xc8, &data, 1); in setbacklight()
3412 i2c_write(gspca_dev, 0xc9, &data, 1); in setbacklight()
3415 i2c_write(gspca_dev, 0xca, &data, 1); in setbacklight()
3417 i2c_write(gspca_dev, 0xcb, &data, 1); in setbacklight()
3420 static void setwb(struct gspca_dev *gspca_dev) in setwb() argument
3425 i2c_write(gspca_dev, 0x16, &data[0], 1); in setwb()
3426 i2c_write(gspca_dev, 0x18, &data[1], 1); in setwb()
3429 static int sd_start(struct gspca_dev *gspca_dev) in sd_start() argument
3431 struct sd *sd = (struct sd *) gspca_dev; in sd_start()
3444 reg_w(gspca_dev, 0x89, 0xf0ff, 0xffff); in sd_start()
3445 reg_w(gspca_dev, 0xa9, 0x8348, 0x000e); in sd_start()
3446 reg_w(gspca_dev, 0xa9, 0x0000, 0x001a); in sd_start()
3451 reg_w(gspca_dev, 0xa0, 0xff, 0xbfec); in sd_start()
3452 reg_w(gspca_dev, 0xa0, 0xff, 0xbfed); in sd_start()
3453 reg_w(gspca_dev, 0xa0, 0xff, 0xbfee); in sd_start()
3454 reg_w(gspca_dev, 0xa0, 0xff, 0xbfef); in sd_start()
3457 if (gspca_dev->cam.cam_mode[gspca_dev->curr_mode].pixelformat in sd_start()
3464 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; in sd_start()
3528 usb_exchange(gspca_dev, init); in sd_start()
3538 usb_exchange(gspca_dev, poxxxx_init_common); in sd_start()
3539 setgamma(gspca_dev); in sd_start()
3540 usb_exchange(gspca_dev, poxxxx_init_start_3); in sd_start()
3545 usb_exchange(gspca_dev, init); in sd_start()
3546 reg_r(gspca_dev, 0x8c, 0x0000, 3); in sd_start()
3547 reg_w(gspca_dev, 0xa0, in sd_start()
3548 gspca_dev->usb_buf[2] & 1 ? 0 : 1, in sd_start()
3555 usb_exchange(gspca_dev, init); in sd_start()
3557 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb84a); in sd_start()
3558 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb85b); in sd_start()
3559 put_tab_to_reg(gspca_dev, GammaT, 17, 0xb86c); in sd_start()
3560 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c); in sd_start()
3565 reg_w(gspca_dev, 0x89, 0x0400, 0x1415); in sd_start()
3568 reg_w(gspca_dev, 0x89, 0x058c, 0x0000); in sd_start()
3575 reg_w(gspca_dev, 0x87, 0xffff, 0xffff); in sd_start()
3576 reg_w(gspca_dev, 0x88, 0xff00, 0xf0f1); in sd_start()
3577 reg_w(gspca_dev, 0xa0, 0x0000, 0xbfff); in sd_start()
3580 usb_exchange(gspca_dev, poxxxx_init_end_2); in sd_start()
3581 setwb(gspca_dev); in sd_start()
3583 reg_w(gspca_dev, 0x89, 0xffff, 0xfdff); in sd_start()
3586 return gspca_dev->usb_err; in sd_start()
3589 static void sd_stopN(struct gspca_dev *gspca_dev) in sd_stopN() argument
3591 struct sd *sd = (struct sd *) gspca_dev; in sd_stopN()
3595 reg_w(gspca_dev, 0x89, 0x058c, 0x00ff); in sd_stopN()
3601 reg_w(gspca_dev, 0x89, 0xffff, 0xffff); in sd_stopN()
3604 reg_w(gspca_dev, 0xa0, 0x01, 0xb301); in sd_stopN()
3605 reg_w(gspca_dev, 0xa0, 0x09, 0xb003); in sd_stopN()
3609 static void sd_stop0(struct gspca_dev *gspca_dev) in sd_stop0() argument
3611 struct sd *sd = (struct sd *) gspca_dev; in sd_stop0()
3613 if (!gspca_dev->present) in sd_stop0()
3617 reg_w(gspca_dev, 0x89, 0x058c, 0x00ff); in sd_stop0()
3619 reg_w(gspca_dev, 0x89, 0xffff, 0xffff); in sd_stop0()
3622 reg_w(gspca_dev, 0xa0, 0x26, 0xb300); in sd_stop0()
3623 reg_w(gspca_dev, 0xa0, 0x04, 0xb300); in sd_stop0()
3624 reg_w(gspca_dev, 0xa0, 0x00, 0xb300); in sd_stop0()
3628 static void sd_pkt_scan(struct gspca_dev *gspca_dev, in sd_pkt_scan() argument
3632 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan()
3635 gspca_dbg(gspca_dev, D_PACK, in sd_pkt_scan()
3637 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); in sd_pkt_scan()
3640 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len); in sd_pkt_scan()
3649 l = gspca_dev->image_len; in sd_pkt_scan()
3650 size = gspca_dev->pixfmt.sizeimage; in sd_pkt_scan()
3654 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); in sd_pkt_scan()
3659 struct gspca_dev *gspca_dev = in sd_s_ctrl() local
3660 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
3661 struct sd *sd = (struct sd *)gspca_dev; in sd_s_ctrl()
3663 gspca_dev->usb_err = 0; in sd_s_ctrl()
3665 if (!gspca_dev->streaming && ctrl->id != V4L2_CID_POWER_LINE_FREQUENCY) in sd_s_ctrl()
3670 setbrightness(gspca_dev, ctrl->val); in sd_s_ctrl()
3673 setcontrast(gspca_dev, ctrl->val); in sd_s_ctrl()
3676 setcolors(gspca_dev, ctrl->val); in sd_s_ctrl()
3679 sethvflip(gspca_dev, sd->hflip->val, sd->vflip->val); in sd_s_ctrl()
3682 setsharpness(gspca_dev, ctrl->val); in sd_s_ctrl()
3685 setautogain(gspca_dev, ctrl->val); in sd_s_ctrl()
3688 setgain(gspca_dev, ctrl->val); in sd_s_ctrl()
3691 setexposure(gspca_dev, ctrl->val); in sd_s_ctrl()
3694 setbacklight(gspca_dev, ctrl->val); in sd_s_ctrl()
3697 setlightfreq(gspca_dev, ctrl->val); in sd_s_ctrl()
3700 return gspca_dev->usb_err; in sd_s_ctrl()
3707 static int sd_init_controls(struct gspca_dev *gspca_dev) in sd_init_controls() argument
3709 struct sd *sd = (struct sd *)gspca_dev; in sd_init_controls()
3710 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
3746 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()