Lines Matching refs:client
162 static struct mt9v022 *to_mt9v022(const struct i2c_client *client) in to_mt9v022() argument
164 return container_of(i2c_get_clientdata(client), struct mt9v022, subdev); in to_mt9v022()
167 static int reg_read(struct i2c_client *client, const u8 reg) in reg_read() argument
169 return i2c_smbus_read_word_swapped(client, reg); in reg_read()
172 static int reg_write(struct i2c_client *client, const u8 reg, in reg_write() argument
175 return i2c_smbus_write_word_swapped(client, reg, data); in reg_write()
178 static int reg_set(struct i2c_client *client, const u8 reg, in reg_set() argument
183 ret = reg_read(client, reg); in reg_set()
186 return reg_write(client, reg, ret | data); in reg_set()
189 static int reg_clear(struct i2c_client *client, const u8 reg, in reg_clear() argument
194 ret = reg_read(client, reg); in reg_clear()
197 return reg_write(client, reg, ret & ~data); in reg_clear()
200 static int mt9v022_init(struct i2c_client *client) in mt9v022_init() argument
202 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_init()
211 ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control); in mt9v022_init()
213 ret = reg_write(client, MT9V022_READ_MODE, 0x300); in mt9v022_init()
218 ret = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x3); in mt9v022_init()
220 ret = reg_write(client, MT9V022_ANALOG_GAIN, 16); in mt9v022_init()
222 ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, 480); in mt9v022_init()
224 ret = reg_write(client, mt9v022->reg->max_total_shutter_width, 480); in mt9v022_init()
227 ret = reg_clear(client, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1); in mt9v022_init()
229 ret = reg_write(client, MT9V022_DIGITAL_TEST_PATTERN, 0); in mt9v022_init()
238 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_stream() local
239 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_stream()
250 if (reg_clear(client, MT9V022_REG32, 0x204)) in mt9v022_s_stream()
263 if (reg_set(client, MT9V022_REG32, 0x204)) in mt9v022_s_stream()
268 if (reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control) < 0) in mt9v022_s_stream()
275 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_crop() local
276 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_crop()
295 ret = reg_read(client, MT9V022_AEC_AGC_ENABLE); in mt9v022_s_crop()
298 ret = reg_write(client, mt9v022->reg->max_total_shutter_width, in mt9v022_s_crop()
311 ret = reg_write(client, MT9V022_COLUMN_START, rect.left); in mt9v022_s_crop()
313 ret = reg_write(client, MT9V022_ROW_START, rect.top); in mt9v022_s_crop()
332 ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width); in mt9v022_s_crop()
334 ret = reg_write(client, MT9V022_WINDOW_HEIGHT, in mt9v022_s_crop()
340 dev_dbg(&client->dev, "Frame %dx%d pixel\n", rect.width, rect.height); in mt9v022_s_crop()
349 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_crop() local
350 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_g_crop()
375 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_fmt() local
376 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_g_fmt()
390 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_fmt() local
391 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_fmt()
437 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_try_fmt() local
438 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_try_fmt()
463 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_chip_ident() local
464 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_g_chip_ident()
469 if (id->match.addr != client->addr) in mt9v022_g_chip_ident()
482 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_register() local
487 if (reg->match.addr != client->addr) in mt9v022_g_register()
491 reg->val = reg_read(client, reg->reg); in mt9v022_g_register()
502 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_register() local
507 if (reg->match.addr != client->addr) in mt9v022_s_register()
510 if (reg_write(client, reg->reg, reg->val) < 0) in mt9v022_s_register()
519 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_power() local
520 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_s_power()
522 return soc_camera_set_power(&client->dev, ssdd, on); in mt9v022_s_power()
530 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_volatile_ctrl() local
538 data = reg_read(client, MT9V022_ANALOG_GAIN); in mt9v022_g_volatile_ctrl()
546 data = reg_read(client, MT9V022_TOTAL_SHUTTER_WIDTH); in mt9v022_g_volatile_ctrl()
554 data = reg_read(client, MT9V022_HORIZONTAL_BLANKING); in mt9v022_g_volatile_ctrl()
560 data = reg_read(client, MT9V022_VERTICAL_BLANKING); in mt9v022_g_volatile_ctrl()
574 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_ctrl() local
580 data = reg_set(client, MT9V022_READ_MODE, 0x10); in mt9v022_s_ctrl()
582 data = reg_clear(client, MT9V022_READ_MODE, 0x10); in mt9v022_s_ctrl()
588 data = reg_set(client, MT9V022_READ_MODE, 0x20); in mt9v022_s_ctrl()
590 data = reg_clear(client, MT9V022_READ_MODE, 0x20); in mt9v022_s_ctrl()
596 if (reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x2) < 0) in mt9v022_s_ctrl()
613 if (reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x2) < 0) in mt9v022_s_ctrl()
616 dev_dbg(&client->dev, "Setting gain from %d to %lu\n", in mt9v022_s_ctrl()
617 reg_read(client, MT9V022_ANALOG_GAIN), gain_val); in mt9v022_s_ctrl()
618 if (reg_write(client, MT9V022_ANALOG_GAIN, gain_val) < 0) in mt9v022_s_ctrl()
624 data = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x1); in mt9v022_s_ctrl()
635 data = reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x1); in mt9v022_s_ctrl()
638 dev_dbg(&client->dev, "Shutter width from %d to %lu\n", in mt9v022_s_ctrl()
639 reg_read(client, MT9V022_TOTAL_SHUTTER_WIDTH), in mt9v022_s_ctrl()
641 if (reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, in mt9v022_s_ctrl()
647 if (reg_write(client, MT9V022_HORIZONTAL_BLANKING, in mt9v022_s_ctrl()
652 if (reg_write(client, MT9V022_VERTICAL_BLANKING, in mt9v022_s_ctrl()
664 static int mt9v022_video_probe(struct i2c_client *client) in mt9v022_video_probe() argument
666 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_video_probe()
667 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_video_probe()
677 data = reg_read(client, MT9V022_CHIP_VERSION); in mt9v022_video_probe()
682 dev_info(&client->dev, "No MT9V022 found, ID register 0x%x\n", in mt9v022_video_probe()
693 ret = reg_write(client, MT9V022_RESET, 1); in mt9v022_video_probe()
698 if (reg_read(client, MT9V022_RESET)) { in mt9v022_video_probe()
699 dev_err(&client->dev, "Resetting MT9V022 failed!\n"); in mt9v022_video_probe()
708 ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11); in mt9v022_video_probe()
712 ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 0x11); in mt9v022_video_probe()
742 dev_info(&client->dev, "Detected a MT9V022 chip ID %x, %s sensor\n", in mt9v022_video_probe()
746 ret = mt9v022_init(client); in mt9v022_video_probe()
748 dev_err(&client->dev, "Failed to initialise the camera\n"); in mt9v022_video_probe()
757 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_skip_top_lines() local
758 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_g_skip_top_lines()
782 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_enum_fmt() local
783 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_enum_fmt()
795 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_g_mbus_config() local
796 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_g_mbus_config()
812 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9v022_s_mbus_config() local
813 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_s_mbus_config()
814 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_s_mbus_config()
841 ret = reg_write(client, mt9v022->reg->pixclk_fv_lv, pixclk); in mt9v022_s_mbus_config()
848 ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control); in mt9v022_s_mbus_config()
852 dev_dbg(&client->dev, "Calculated pixclk 0x%x, chip control 0x%x\n", in mt9v022_s_mbus_config()
881 static int mt9v022_probe(struct i2c_client *client, in mt9v022_probe() argument
885 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_probe()
886 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); in mt9v022_probe()
891 dev_err(&client->dev, "MT9V022 driver needs platform data\n"); in mt9v022_probe()
901 mt9v022 = devm_kzalloc(&client->dev, sizeof(struct mt9v022), GFP_KERNEL); in mt9v022_probe()
906 v4l2_i2c_subdev_init(&mt9v022->subdev, client, &mt9v022_subdev_ops); in mt9v022_probe()
941 dev_err(&client->dev, "control initialisation err %d\n", err); in mt9v022_probe()
960 ret = mt9v022_video_probe(client); in mt9v022_probe()
967 static int mt9v022_remove(struct i2c_client *client) in mt9v022_remove() argument
969 struct mt9v022 *mt9v022 = to_mt9v022(client); in mt9v022_remove()
970 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9v022_remove()