static int cs5345_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct v4l2_subdev *sd; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); if (sd == NULL) return -ENOMEM; v4l2_i2c_subdev_init(sd, client, &cs5345_ops); cs5345_write(sd, 0x02, 0x00); cs5345_write(sd, 0x04, 0x01); cs5345_write(sd, 0x09, 0x01); return 0; }
static int mt9v011_probe(struct i2c_client *c, const struct i2c_device_id *id) { u16 version; struct mt9v011 *core; struct v4l2_subdev *sd; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(c->adapter, I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EIO; core = kzalloc(sizeof(struct mt9v011), GFP_KERNEL); if (!core) return -ENOMEM; sd = &core->sd; v4l2_i2c_subdev_init(sd, c, &mt9v011_ops); /* Check if the sensor is really a MT9V011 */ version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION); if ((version != MT9V011_VERSION) && (version != MT9V011_REV_B_VERSION)) { v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n", version); kfree(core); return -EINVAL; } core->global_gain = 0x0024; core->width = 640; core->height = 480; core->xtal = 27000000; /* Hz */ v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n", c->addr << 1, c->adapter->name, version); return 0; }
static int cs53l32a_probe(struct i2c_client *client) { int i; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; snprintf(client->name, sizeof(client->name) - 1, "cs53l32a"); v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); for (i = 1; i <= 7; i++) { u8 v = cs53l32a_read(client, i); v4l_dbg(1, debug, client, "Read Reg %d %02x\n", i, v); } /* Set cs53l32a internal register for Adaptec 2010/2410 setup */ cs53l32a_write(client, 0x01, (u8) 0x21); cs53l32a_write(client, 0x02, (u8) 0x29); cs53l32a_write(client, 0x03, (u8) 0x30); cs53l32a_write(client, 0x04, (u8) 0x00); cs53l32a_write(client, 0x05, (u8) 0x00); cs53l32a_write(client, 0x06, (u8) 0x00); cs53l32a_write(client, 0x07, (u8) 0x00); /* Display results, should be 0x21,0x29,0x30,0x00,0x00,0x00,0x00 */ for (i = 1; i <= 7; i++) { u8 v = cs53l32a_read(client, i); v4l_dbg(1, debug, client, "Read Reg %d %02x\n", i, v); } return 0; }
static int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; struct v4l2_subdev *sd; int ret; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); ret = i2c_smbus_write_byte_data(client, ADV7180_INPUT_CONTROL_REG, ADV7180_INPUT_CONTROL_PAL_BG_NTSC_J_SECAM); if (ret > 0) ret = i2c_smbus_write_byte_data(client, ADV7180_AUTODETECT_ENABLE_REG, ADV7180_AUTODETECT_DEFAULT); if (ret < 0) { printk(KERN_ERR DRIVER_NAME ": Failed to communicate to chip: %d\n", ret); return ret; } return 0; }
static int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; struct v4l2_subdev *sd; int ret; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr, client->adapter->name); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; state->client = client; state->field = V4L2_FIELD_INTERLACED; state->chip_info = (struct adv7180_chip_info *)id->driver_data; if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) { state->csi_client = i2c_new_dummy(client->adapter, ADV7180_DEFAULT_CSI_I2C_ADDR); if (!state->csi_client) return -ENOMEM; } if (state->chip_info->flags & ADV7180_FLAG_I2P) { state->vpp_client = i2c_new_dummy(client->adapter, ADV7180_DEFAULT_VPP_I2C_ADDR); if (!state->vpp_client) { ret = -ENOMEM; goto err_unregister_csi_client; } } state->irq = client->irq; mutex_init(&state->mutex); state->autodetect = true; if (state->chip_info->flags & ADV7180_FLAG_RESET_POWERED) state->powered = true; else state->powered = false; state->input = 0; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE; ret = adv7180_init_controls(state); if (ret) goto err_unregister_vpp_client; state->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER; ret = media_entity_pads_init(&sd->entity, 1, &state->pad); if (ret) goto err_free_ctrl; ret = init_device(state); if (ret) goto err_media_entity_cleanup; if (state->irq) { ret = request_threaded_irq(client->irq, NULL, adv7180_irq, IRQF_ONESHOT | IRQF_TRIGGER_FALLING, KBUILD_MODNAME, state); if (ret) goto err_media_entity_cleanup; } ret = v4l2_async_register_subdev(sd); if (ret) goto err_free_irq; return 0; err_free_irq: if (state->irq > 0) free_irq(client->irq, state); err_media_entity_cleanup: media_entity_cleanup(&sd->entity); err_free_ctrl: adv7180_exit_controls(state); err_unregister_vpp_client: if (state->chip_info->flags & ADV7180_FLAG_I2P) i2c_unregister_device(state->vpp_client); err_unregister_csi_client: if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) i2c_unregister_device(state->csi_client); mutex_destroy(&state->mutex); return ret; }
static __devinit int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; struct v4l2_subdev *sd; int ret; /* */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); if (state == NULL) { ret = -ENOMEM; goto err; } state->irq = client->irq; INIT_WORK(&state->work, adv7180_work); mutex_init(&state->mutex); state->autodetect = true; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); /* */ /* */ ret = i2c_smbus_write_byte_data(client, ADV7180_INPUT_CONTROL_REG, ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_AUTODETECT_ENABLE_REG, ADV7180_AUTODETECT_DEFAULT); if (ret < 0) goto err_unreg_subdev; /* */ ret = i2c_smbus_write_byte_data(client, ADV7180_EXTENDED_OUTPUT_CONTROL_REG, ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS); if (ret < 0) goto err_unreg_subdev; /* */ __adv7180_status(client, NULL, &state->curr_norm); /* */ if (state->irq > 0) { ret = request_irq(state->irq, adv7180_irq, 0, DRIVER_NAME, state); if (ret) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, ADV7180_ADI_CTRL_IRQ_SPACE); if (ret < 0) goto err_unreg_subdev; /* */ ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI, ADV7180_ICONF1_ACTIVE_LOW | ADV7180_ICONF1_PSYNC_ONLY); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0); if (ret < 0) goto err_unreg_subdev; /* */ ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI, ADV7180_IRQ3_AD_CHANGE); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, 0); if (ret < 0) goto err_unreg_subdev; } return 0; err_unreg_subdev: mutex_destroy(&state->mutex); v4l2_device_unregister_subdev(sd); kfree(state); err: printk(KERN_ERR DRIVER_NAME ": Failed to probe: %d\n", ret); return ret; }
static int mt9v011_probe(struct i2c_client *c, const struct i2c_device_id *id) { u16 version; struct mt9v011 *core; struct v4l2_subdev *sd; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(c->adapter, I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EIO; core = kzalloc(sizeof(struct mt9v011), GFP_KERNEL); if (!core) return -ENOMEM; sd = &core->sd; v4l2_i2c_subdev_init(sd, c, &mt9v011_ops); /* Check if the sensor is really a MT9V011 */ version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION); if ((version != MT9V011_VERSION) && (version != MT9V011_REV_B_VERSION)) { v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n", version); kfree(core); return -EINVAL; } v4l2_ctrl_handler_init(&core->ctrls, 5); v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, V4L2_CID_GAIN, 0, (1 << 12) - 1 - 0x20, 1, 0x20); v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, V4L2_CID_EXPOSURE, 0, 2047, 1, 0x01fc); v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, V4L2_CID_RED_BALANCE, -(1 << 9), (1 << 9) - 1, 1, 0); v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, V4L2_CID_BLUE_BALANCE, -(1 << 9), (1 << 9) - 1, 1, 0); v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); v4l2_ctrl_new_std(&core->ctrls, &mt9v011_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); if (core->ctrls.error) { int ret = core->ctrls.error; v4l2_err(sd, "control initialization error %d\n", ret); v4l2_ctrl_handler_free(&core->ctrls); kfree(core); return ret; } core->sd.ctrl_handler = &core->ctrls; core->global_gain = 0x0024; core->exposure = 0x01fc; core->width = 640; core->height = 480; core->xtal = 27000000; /* Hz */ if (c->dev.platform_data) { struct mt9v011_platform_data *pdata = c->dev.platform_data; core->xtal = pdata->xtal; v4l2_dbg(1, debug, sd, "xtal set to %d.%03d MHz\n", core->xtal / 1000000, (core->xtal / 1000) % 1000); } v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n", c->addr << 1, c->adapter->name, version); return 0; }
static int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; struct v4l2_subdev *sd; struct soc_camera_device *icd = client->dev.platform_data; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); int ret; printk("%s %d\n", __func__, __LINE__); /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; printk("%s %d\n", __func__, __LINE__); v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); printk("%s %d\n", __func__, __LINE__); state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); if (state == NULL) { ret = -ENOMEM; goto err; } printk("%s %d\n", __func__, __LINE__); rk30_mux_api_set(GPIO0B7_I2S8CHSDO3_NAME, GPIO0B_GPIO0B7); ret = gpio_request(ADV7180_CVBS_IN_DET, "ADV_CVBS_INT"); if (ret != 0) { gpio_free(ADV7180_CVBS_IN_DET); printk(KERN_ERR "request ADV7180_CVBS_IN_DET pin fail!\n"); return -1; } gpio_direction_input(ADV7180_CVBS_IN_DET); ret = gpio_request(ADV7180_YCRCB_IN_DET, "ADV_YCRCB_INT"); if (ret != 0) { gpio_free(ADV7180_YCRCB_IN_DET); printk(KERN_ERR "request ADV7180_YCRCB_IN_DET pin fail!\n"); return -1; } gpio_direction_input(ADV7180_YCRCB_IN_DET); state->cvbs_irq = gpio_to_irq(ADV7180_CVBS_IN_DET); state->ycrcb_irq = gpio_to_irq(ADV7180_YCRCB_IN_DET); INIT_WORK(&state->cvbs_work, adv7180_cvbs_work); INIT_WORK(&state->ycrcb_work, adv7180_ycrcb_work); mutex_init(&state->mutex); state->autodetect = true; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); state->icd = icd; icd->ops = &adv7180_sensor_ops; icd->user_width = adv7180_pic_sizes[0].width; icd->user_height = adv7180_pic_sizes[0].height; icd->colorspace = adv7180_colour_fmts[0].colorspace; adv7180_pwr_ctl(icd, 1); ret = 0; printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_read_byte_data(client, ADV7180_IDENT_REG); /* if (ret != ADV7180_ID_7180) goto err_unreg_subdev; */ printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_write_byte_data(client, 0x1d, 0x00); /* 27M/28M crystal */ int i; if(gpio_get_value(ADV7180_YCRCB_IN_DET)==GPIO_LOW) { printk("adv7180 ycrcb init\n"); for(i=0; i<15; i++) i2c_smbus_write_byte_data(client, init_ycrcb[i].reg, init_ycrcb[i].val); } else { printk("adv7180 cvbs init\n"); for(i=0; i<15; i++) i2c_smbus_write_byte_data(client, init_cvbs[i].reg, init_cvbs[i].val); } #if 0 /* register for interrupts */ if (state->irq > 0) { ret = request_irq(state->irq, adv7180_irq, 0, DRIVER_NAME, state); if (ret) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, ADV7180_ADI_CTRL_IRQ_SPACE); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); /* config the Interrupt pin to be active low */ ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI, ADV7180_ICONF1_ACTIVE_LOW | ADV7180_ICONF1_PSYNC_ONLY); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); /* enable AD change interrupts interrupts */ ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI, ADV7180_IRQ3_AD_CHANGE); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, 0); if (ret < 0) goto err_unreg_subdev; printk("%s %d\n", __func__, __LINE__); } #endif adv7180_pwr_ctl(icd, 0); ret = device_create_file(&client->dev, &adv7180_dev_attr); if (ret) { printk("create device file failed!\n"); } v4l_info(client, "chip probe success @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); return 0; err_unreg_subdev: adv7180_pwr_ctl(icd, 0); mutex_destroy(&state->mutex); v4l2_device_unregister_subdev(sd); kfree(state); err: printk(KERN_ERR DRIVER_NAME ": Failed to probe: %d\n", ret); return ret; }
static int cs53l32a_command(struct i2c_client *client, unsigned cmd, void *arg) { struct v4l2_routing *route = arg; struct v4l2_control *ctrl = arg; switch (cmd) { case VIDIOC_INT_G_AUDIO_ROUTING: route->input = (cs53l32a_read(client, 0x01) >> 4) & 3; route->output = 0; break; case VIDIOC_INT_S_AUDIO_ROUTING: /* There are 2 physical inputs, but the second input can be placed in two modes, the first mode bypasses the PGA (gain), the second goes through the PGA. Hence there are three possible inputs to choose from. */ if (route->input > 2) { v4l_err(client, "Invalid input %d.\n", route->input); return -EINVAL; } cs53l32a_write(client, 0x01, 0x01 + (route->input << 4)); break; case VIDIOC_G_CTRL: if (ctrl->id == V4L2_CID_AUDIO_MUTE) { ctrl->value = (cs53l32a_read(client, 0x03) & 0xc0) != 0; break; } if (ctrl->id != V4L2_CID_AUDIO_VOLUME) return -EINVAL; ctrl->value = (s8)cs53l32a_read(client, 0x04); break; case VIDIOC_S_CTRL: if (ctrl->id == V4L2_CID_AUDIO_MUTE) { cs53l32a_write(client, 0x03, ctrl->value ? 0xf0 : 0x30); break; } if (ctrl->id != V4L2_CID_AUDIO_VOLUME) return -EINVAL; if (ctrl->value > 12 || ctrl->value < -96) return -EINVAL; cs53l32a_write(client, 0x04, (u8) ctrl->value); cs53l32a_write(client, 0x05, (u8) ctrl->value); break; case VIDIOC_G_CHIP_IDENT: return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_CS53l32A, 0); case VIDIOC_LOG_STATUS: { u8 v = cs53l32a_read(client, 0x01); u8 m = cs53l32a_read(client, 0x03); s8 vol = cs53l32a_read(client, 0x04); v4l_info(client, "Input: %d%s\n", (v >> 4) & 3, (m & 0xC0) ? " (muted)" : ""); v4l_info(client, "Volume: %d dB\n", vol); break; } default: return -EINVAL; } return 0; }
static int cs5345_command(struct i2c_client *client, unsigned cmd, void *arg) { struct v4l2_routing *route = arg; struct v4l2_control *ctrl = arg; switch (cmd) { case VIDIOC_INT_G_AUDIO_ROUTING: route->input = cs5345_read(client, 0x09) & 7; route->input |= cs5345_read(client, 0x05) & 0x70; route->output = 0; break; case VIDIOC_INT_S_AUDIO_ROUTING: if ((route->input & 0xf) > 6) { v4l_err(client, "Invalid input %d.\n", route->input); return -EINVAL; } cs5345_write(client, 0x09, route->input & 0xf); cs5345_write(client, 0x05, route->input & 0xf0); break; case VIDIOC_G_CTRL: if (ctrl->id == V4L2_CID_AUDIO_MUTE) { ctrl->value = (cs5345_read(client, 0x04) & 0x08) != 0; break; } if (ctrl->id != V4L2_CID_AUDIO_VOLUME) return -EINVAL; ctrl->value = cs5345_read(client, 0x07) & 0x3f; if (ctrl->value >= 32) ctrl->value = ctrl->value - 64; break; case VIDIOC_S_CTRL: break; if (ctrl->id == V4L2_CID_AUDIO_MUTE) { cs5345_write(client, 0x04, ctrl->value ? 0x80 : 0); break; } if (ctrl->id != V4L2_CID_AUDIO_VOLUME) return -EINVAL; if (ctrl->value > 24 || ctrl->value < -24) return -EINVAL; cs5345_write(client, 0x07, ((u8)ctrl->value) & 0x3f); cs5345_write(client, 0x08, ((u8)ctrl->value) & 0x3f); break; #ifdef CONFIG_VIDEO_ADV_DEBUG case VIDIOC_DBG_G_REGISTER: case VIDIOC_DBG_S_REGISTER: { struct v4l2_register *reg = arg; if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) return -EINVAL; if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (cmd == VIDIOC_DBG_G_REGISTER) reg->val = cs5345_read(client, reg->reg & 0x1f); else cs5345_write(client, reg->reg & 0x1f, reg->val & 0x1f); break; } #endif case VIDIOC_G_CHIP_IDENT: return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_CS5345, 0); case VIDIOC_LOG_STATUS: { u8 v = cs5345_read(client, 0x09) & 7; u8 m = cs5345_read(client, 0x04); int vol = cs5345_read(client, 0x08) & 0x3f; v4l_info(client, "Input: %d%s\n", v, (m & 0x80) ? " (muted)" : ""); if (vol >= 32) vol = vol - 64; v4l_info(client, "Volume: %d dB\n", vol); break; } default: return -EINVAL; } return 0; }
static __devinit int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; struct v4l2_subdev *sd; int ret; /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); if (state == NULL) { ret = -ENOMEM; goto err; } state->irq = client->irq; INIT_WORK(&state->work, adv7180_work); mutex_init(&state->mutex); state->autodetect = true; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); /* Initialize adv7180 */ /* Enable autodetection */ ret = i2c_smbus_write_byte_data(client, ADV7180_INPUT_CONTROL_REG, ADV7180_INPUT_CONTROL_AD_PAL_BG_NTSC_J_SECAM); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_AUTODETECT_ENABLE_REG, ADV7180_AUTODETECT_DEFAULT); if (ret < 0) goto err_unreg_subdev; /* ITU-R BT.656-4 compatible */ ret = i2c_smbus_write_byte_data(client, ADV7180_EXTENDED_OUTPUT_CONTROL_REG, ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS); if (ret < 0) goto err_unreg_subdev; /* read current norm */ __adv7180_status(client, NULL, &state->curr_norm); /* register for interrupts */ if (state->irq > 0) { ret = request_irq(state->irq, adv7180_irq, 0, DRIVER_NAME, state); if (ret) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, ADV7180_ADI_CTRL_IRQ_SPACE); if (ret < 0) goto err_unreg_subdev; /* config the Interrupt pin to be active low */ ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI, ADV7180_ICONF1_ACTIVE_LOW | ADV7180_ICONF1_PSYNC_ONLY); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0); if (ret < 0) goto err_unreg_subdev; /* enable AD change interrupts interrupts */ ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI, ADV7180_IRQ3_AD_CHANGE); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, 0); if (ret < 0) goto err_unreg_subdev; } return 0; err_unreg_subdev: mutex_destroy(&state->mutex); v4l2_device_unregister_subdev(sd); kfree(state); err: ; return ret; }
static int tw2804_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct i2c_adapter *adapter = client->adapter; struct tw2804 *state; struct v4l2_subdev *sd; struct v4l2_ctrl *ctrl; int err; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -ENODEV; state = kzalloc(sizeof(struct tw2804), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &tw2804_ops); state->channel = -1; state->norm = V4L2_STD_NTSC; v4l2_ctrl_handler_init(&state->hdl, 10); v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_CONTRAST, 0, 255, 1, 128); v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_SATURATION, 0, 255, 1, 128); v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_HUE, 0, 255, 1, 128); v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_COLOR_KILLER, 0, 1, 1, 0); v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_AUTOGAIN, 0, 1, 1, 0); ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_GAIN, 0, 255, 1, 128); if (ctrl) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_CHROMA_GAIN, 0, 255, 1, 128); if (ctrl) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_BLUE_BALANCE, 0, 255, 1, 122); if (ctrl) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops, V4L2_CID_RED_BALANCE, 0, 255, 1, 122); if (ctrl) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; sd->ctrl_handler = &state->hdl; err = state->hdl.error; if (err) { v4l2_ctrl_handler_free(&state->hdl); kfree(state); return err; } v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); return 0; }
static __devinit int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adv7180_state *state; struct v4l2_subdev *sd; struct soc_camera_device *icd = client->dev.platform_data; int ret; #ifndef CONFIG_ARCH_RK29 /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; #endif v4l_info(client, "chip found @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL); if (state == NULL) { ret = -ENOMEM; goto err; } state->irq = client->irq; INIT_WORK(&state->work, adv7180_work); mutex_init(&state->mutex); state->autodetect = true; sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); state->icd = icd; icd->ops = &adv7180_sensor_ops; icd->user_width = adv7180_pic_sizes[0].width; icd->user_height = adv7180_pic_sizes[0].height; icd->colorspace = adv7180_colour_fmts[0].colorspace; adv7180_pwr_ctl(icd, 1); ret = 0; ret = i2c_smbus_read_byte_data(client, ADV7180_IDENT_REG); if (ret != ADV7180_ID_7180) goto err_unreg_subdev; /* register for interrupts */ if (state->irq > 0) { ret = request_irq(state->irq, adv7180_irq, 0, DRIVER_NAME, state); if (ret) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, ADV7180_ADI_CTRL_IRQ_SPACE); if (ret < 0) goto err_unreg_subdev; /* config the Interrupt pin to be active low */ ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI, ADV7180_ICONF1_ACTIVE_LOW | ADV7180_ICONF1_PSYNC_ONLY); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0); if (ret < 0) goto err_unreg_subdev; /* enable AD change interrupts interrupts */ ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI, ADV7180_IRQ3_AD_CHANGE); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0); if (ret < 0) goto err_unreg_subdev; ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, 0); if (ret < 0) goto err_unreg_subdev; } adv7180_pwr_ctl(icd, 0); v4l_info(client, "chip probe success @ 0x%02x (%s)\n", client->addr << 1, client->adapter->name); return 0; err_unreg_subdev: adv7180_pwr_ctl(icd, 0); mutex_destroy(&state->mutex); v4l2_device_unregister_subdev(sd); kfree(state); err: printk(KERN_ERR DRIVER_NAME ": Failed to probe: %d\n", ret); return ret; }