Lines Matching refs:client
168 static struct mt9v022 *to_mt9v022(const struct i2c_client *client) in to_mt9v022() argument
170 return container_of(i2c_get_clientdata(client), struct mt9v022, subdev); in to_mt9v022()
173 static int reg_read(struct i2c_client *client, const u8 reg) in reg_read() argument
175 return i2c_smbus_read_word_swapped(client, reg); in reg_read()
178 static int reg_write(struct i2c_client *client, const u8 reg, in reg_write() argument
181 return i2c_smbus_write_word_swapped(client, reg, data); in reg_write()
184 static int reg_set(struct i2c_client *client, const u8 reg, in reg_set() argument
189 ret = reg_read(client, reg); in reg_set()
192 return reg_write(client, reg, ret | data); in reg_set()
195 static int reg_clear(struct i2c_client *client, const u8 reg, in reg_clear() argument
200 ret = reg_read(client, reg); in reg_clear()
203 return reg_write(client, reg, ret & ~data); in reg_clear()
206 static int mt9v022_init(struct i2c_client *client) in mt9v022_init() argument
208 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_init()
217 ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control); in mt9v022_init()
219 ret = reg_write(client, MT9V022_READ_MODE, 0x300); in mt9v022_init()
224 ret = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x3); in mt9v022_init()
226 ret = reg_write(client, MT9V022_ANALOG_GAIN, 16); in mt9v022_init()
228 ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, 480); in mt9v022_init()
230 ret = reg_write(client, mt9v022->reg->max_total_shutter_width, 480); in mt9v022_init()
233 ret = reg_clear(client, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1); in mt9v022_init()
235 ret = reg_write(client, MT9V022_DIGITAL_TEST_PATTERN, 0); in mt9v022_init()
244 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_stream() local
245 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_stream()
256 if (reg_clear(client, MT9V022_REG32, 0x204)) in mt9v022_s_stream()
269 if (reg_set(client, MT9V022_REG32, 0x204)) in mt9v022_s_stream()
274 if (reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control) < 0) in mt9v022_s_stream()
281 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_crop() local
282 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_crop()
301 ret = reg_read(client, MT9V022_AEC_AGC_ENABLE); in mt9v022_s_crop()
304 ret = reg_write(client, mt9v022->reg->max_total_shutter_width, in mt9v022_s_crop()
317 ret = reg_write(client, MT9V022_COLUMN_START, rect.left); in mt9v022_s_crop()
319 ret = reg_write(client, MT9V022_ROW_START, rect.top); in mt9v022_s_crop()
338 ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width); in mt9v022_s_crop()
340 ret = reg_write(client, MT9V022_WINDOW_HEIGHT, in mt9v022_s_crop()
346 dev_dbg(&client->dev, "Frame %dx%d pixel\n", rect.width, rect.height); in mt9v022_s_crop()
355 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_crop() local
356 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_g_crop()
383 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_get_fmt() local
384 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_get_fmt()
401 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_fmt() local
402 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_fmt()
450 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_set_fmt() local
451 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_set_fmt()
483 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_register() local
489 reg->val = reg_read(client, reg->reg); in mt9v022_g_register()
500 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_register() local
505 if (reg_write(client, reg->reg, reg->val) < 0) in mt9v022_s_register()
514 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_power() local
515 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_s_power()
516 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_power()
518 return soc_camera_set_power(&client->dev, ssdd, mt9v022->clk, on); in mt9v022_s_power()
526 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_volatile_ctrl() local
534 data = reg_read(client, MT9V022_ANALOG_GAIN); in mt9v022_g_volatile_ctrl()
542 data = reg_read(client, MT9V022_TOTAL_SHUTTER_WIDTH); in mt9v022_g_volatile_ctrl()
550 data = reg_read(client, MT9V022_HORIZONTAL_BLANKING); in mt9v022_g_volatile_ctrl()
556 data = reg_read(client, MT9V022_VERTICAL_BLANKING); in mt9v022_g_volatile_ctrl()
570 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_ctrl() local
576 data = reg_set(client, MT9V022_READ_MODE, 0x10); in mt9v022_s_ctrl()
578 data = reg_clear(client, MT9V022_READ_MODE, 0x10); in mt9v022_s_ctrl()
584 data = reg_set(client, MT9V022_READ_MODE, 0x20); in mt9v022_s_ctrl()
586 data = reg_clear(client, MT9V022_READ_MODE, 0x20); in mt9v022_s_ctrl()
592 if (reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x2) < 0) in mt9v022_s_ctrl()
609 if (reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x2) < 0) in mt9v022_s_ctrl()
612 dev_dbg(&client->dev, "Setting gain from %d to %lu\n", in mt9v022_s_ctrl()
613 reg_read(client, MT9V022_ANALOG_GAIN), gain_val); in mt9v022_s_ctrl()
614 if (reg_write(client, MT9V022_ANALOG_GAIN, gain_val) < 0) in mt9v022_s_ctrl()
620 data = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x1); in mt9v022_s_ctrl()
631 data = reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x1); in mt9v022_s_ctrl()
634 dev_dbg(&client->dev, "Shutter width from %d to %lu\n", in mt9v022_s_ctrl()
635 reg_read(client, MT9V022_TOTAL_SHUTTER_WIDTH), in mt9v022_s_ctrl()
637 if (reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, in mt9v022_s_ctrl()
643 if (reg_write(client, MT9V022_HORIZONTAL_BLANKING, in mt9v022_s_ctrl()
648 if (reg_write(client, MT9V022_VERTICAL_BLANKING, in mt9v022_s_ctrl()
660 static int mt9v022_video_probe(struct i2c_client *client) in mt9v022_video_probe() argument
662 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_video_probe()
663 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_video_probe()
673 data = reg_read(client, MT9V022_CHIP_VERSION); in mt9v022_video_probe()
678 dev_info(&client->dev, "No MT9V022 found, ID register 0x%x\n", in mt9v022_video_probe()
689 ret = reg_write(client, MT9V022_RESET, 1); in mt9v022_video_probe()
694 if (reg_read(client, MT9V022_RESET)) { in mt9v022_video_probe()
695 dev_err(&client->dev, "Resetting MT9V022 failed!\n"); in mt9v022_video_probe()
704 ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11); in mt9v022_video_probe()
708 ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 0x11); in mt9v022_video_probe()
738 dev_info(&client->dev, "Detected a MT9V022 chip ID %x, %s sensor\n", in mt9v022_video_probe()
742 ret = mt9v022_init(client); in mt9v022_video_probe()
744 dev_err(&client->dev, "Failed to initialise the camera\n"); in mt9v022_video_probe()
753 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_skip_top_lines() local
754 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_g_skip_top_lines()
778 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_enum_mbus_code() local
779 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_enum_mbus_code()
791 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_mbus_config() local
792 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_g_mbus_config()
808 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_mbus_config() local
809 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_s_mbus_config()
810 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_mbus_config()
837 ret = reg_write(client, mt9v022->reg->pixclk_fv_lv, pixclk); in mt9v022_s_mbus_config()
844 ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control); in mt9v022_s_mbus_config()
848 dev_dbg(&client->dev, "Calculated pixclk 0x%x, chip control 0x%x\n", in mt9v022_s_mbus_config()
880 static int mt9v022_probe(struct i2c_client *client, in mt9v022_probe() argument
884 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_probe()
885 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); in mt9v022_probe()
890 dev_err(&client->dev, "MT9V022 driver needs platform data\n"); in mt9v022_probe()
900 mt9v022 = devm_kzalloc(&client->dev, sizeof(struct mt9v022), GFP_KERNEL); in mt9v022_probe()
905 v4l2_i2c_subdev_init(&mt9v022->subdev, client, &mt9v022_subdev_ops); in mt9v022_probe()
940 dev_err(&client->dev, "control initialisation err %d\n", err); in mt9v022_probe()
959 mt9v022->clk = v4l2_clk_get(&client->dev, "mclk"); in mt9v022_probe()
965 ret = mt9v022_video_probe(client); in mt9v022_probe()
975 static int mt9v022_remove(struct i2c_client *client) in mt9v022_remove() argument
977 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_remove()
978 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_remove()