Lines Matching refs:client
86 static struct mt9t031 *to_mt9t031(const struct i2c_client *client) in to_mt9t031() argument
88 return container_of(i2c_get_clientdata(client), struct mt9t031, subdev); in to_mt9t031()
91 static int reg_read(struct i2c_client *client, const u8 reg) in reg_read() argument
93 return i2c_smbus_read_word_swapped(client, reg); in reg_read()
96 static int reg_write(struct i2c_client *client, const u8 reg, in reg_write() argument
99 return i2c_smbus_write_word_swapped(client, reg, data); in reg_write()
102 static int reg_set(struct i2c_client *client, const u8 reg, in reg_set() argument
107 ret = reg_read(client, reg); in reg_set()
110 return reg_write(client, reg, ret | data); in reg_set()
113 static int reg_clear(struct i2c_client *client, const u8 reg, in reg_clear() argument
118 ret = reg_read(client, reg); in reg_clear()
121 return reg_write(client, reg, ret & ~data); in reg_clear()
124 static int set_shutter(struct i2c_client *client, const u32 data) in set_shutter() argument
128 ret = reg_write(client, MT9T031_SHUTTER_WIDTH_UPPER, data >> 16); in set_shutter()
131 ret = reg_write(client, MT9T031_SHUTTER_WIDTH, data & 0xffff); in set_shutter()
136 static int get_shutter(struct i2c_client *client, u32 *data) in get_shutter() argument
140 ret = reg_read(client, MT9T031_SHUTTER_WIDTH_UPPER); in get_shutter()
144 ret = reg_read(client, MT9T031_SHUTTER_WIDTH); in get_shutter()
150 static int mt9t031_idle(struct i2c_client *client) in mt9t031_idle() argument
155 ret = reg_write(client, MT9T031_RESET, 1); in mt9t031_idle()
157 ret = reg_write(client, MT9T031_RESET, 0); in mt9t031_idle()
159 ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 2); in mt9t031_idle()
166 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_stream() local
171 ret = reg_set(client, MT9T031_OUTPUT_CONTROL, 2); in mt9t031_s_stream()
174 ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 2); in mt9t031_s_stream()
201 static int mt9t031_set_params(struct i2c_client *client, in mt9t031_set_params() argument
204 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_set_params()
240 dev_dbg(&client->dev, "skip %u:%u, rect %ux%u@%u:%u\n", in mt9t031_set_params()
244 ret = reg_set(client, MT9T031_OUTPUT_CONTROL, 1); in mt9t031_set_params()
249 ret = reg_write(client, MT9T031_HORIZONTAL_BLANKING, hblank); in mt9t031_set_params()
251 ret = reg_write(client, MT9T031_VERTICAL_BLANKING, vblank); in mt9t031_set_params()
256 ret = reg_write(client, MT9T031_COLUMN_ADDRESS_MODE, in mt9t031_set_params()
259 ret = reg_write(client, MT9T031_ROW_ADDRESS_MODE, in mt9t031_set_params()
262 dev_dbg(&client->dev, "new physical left %u, top %u\n", in mt9t031_set_params()
270 ret = reg_write(client, MT9T031_COLUMN_START, rect->left); in mt9t031_set_params()
272 ret = reg_write(client, MT9T031_ROW_START, rect->top); in mt9t031_set_params()
274 ret = reg_write(client, MT9T031_WINDOW_WIDTH, rect->width - 1); in mt9t031_set_params()
276 ret = reg_write(client, MT9T031_WINDOW_HEIGHT, in mt9t031_set_params()
281 ret = set_shutter(client, mt9t031->total_h); in mt9t031_set_params()
286 ret = reg_clear(client, MT9T031_OUTPUT_CONTROL, 1); in mt9t031_set_params()
300 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_crop() local
301 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_s_crop()
312 return mt9t031_set_params(client, &rect, mt9t031->xskip, mt9t031->yskip); in mt9t031_s_crop()
317 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_crop() local
318 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_g_crop()
345 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_get_fmt() local
346 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_get_fmt()
369 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_set_fmt() local
370 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_set_fmt()
399 return mt9t031_set_params(client, &rect, xskip, yskip); in mt9t031_set_fmt()
406 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_register() local
412 reg->val = reg_read(client, reg->reg); in mt9t031_g_register()
423 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_register() local
428 if (reg_write(client, reg->reg, reg->val) < 0) in mt9t031_s_register()
459 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_ctrl() local
466 data = reg_set(client, MT9T031_READ_MODE_2, 0x8000); in mt9t031_s_ctrl()
468 data = reg_clear(client, MT9T031_READ_MODE_2, 0x8000); in mt9t031_s_ctrl()
474 data = reg_set(client, MT9T031_READ_MODE_2, 0x4000); in mt9t031_s_ctrl()
476 data = reg_clear(client, MT9T031_READ_MODE_2, 0x4000); in mt9t031_s_ctrl()
487 dev_dbg(&client->dev, "Setting gain %d\n", data); in mt9t031_s_ctrl()
488 data = reg_write(client, MT9T031_GLOBAL_GAIN, data); in mt9t031_s_ctrl()
507 dev_dbg(&client->dev, "Set gain from 0x%x to 0x%x\n", in mt9t031_s_ctrl()
508 reg_read(client, MT9T031_GLOBAL_GAIN), data); in mt9t031_s_ctrl()
509 data = reg_write(client, MT9T031_GLOBAL_GAIN, data); in mt9t031_s_ctrl()
522 get_shutter(client, &old); in mt9t031_s_ctrl()
523 dev_dbg(&client->dev, "Set shutter from %u to %u\n", in mt9t031_s_ctrl()
525 if (set_shutter(client, shutter) < 0) in mt9t031_s_ctrl()
532 if (set_shutter(client, mt9t031->total_h) < 0) in mt9t031_s_ctrl()
561 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_runtime_resume() local
562 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_runtime_resume()
570 ret = reg_write(client, MT9T031_COLUMN_ADDRESS_MODE, in mt9t031_runtime_resume()
575 ret = reg_write(client, MT9T031_ROW_ADDRESS_MODE, in mt9t031_runtime_resume()
595 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_power() local
596 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_s_power()
597 struct video_device *vdev = soc_camera_i2c_to_vdev(client); in mt9t031_s_power()
598 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_s_power()
602 ret = soc_camera_power_on(&client->dev, ssdd, mt9t031->clk); in mt9t031_s_power()
611 soc_camera_power_off(&client->dev, ssdd, mt9t031->clk); in mt9t031_s_power()
621 static int mt9t031_video_probe(struct i2c_client *client) in mt9t031_video_probe() argument
623 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_video_probe()
631 ret = mt9t031_idle(client); in mt9t031_video_probe()
633 dev_err(&client->dev, "Failed to initialise the camera\n"); in mt9t031_video_probe()
638 data = reg_read(client, MT9T031_CHIP_VERSION); in mt9t031_video_probe()
644 dev_err(&client->dev, in mt9t031_video_probe()
650 dev_info(&client->dev, "Detected a MT9T031 chip ID %x\n", data); in mt9t031_video_probe()
662 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_skip_top_lines() local
663 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_g_skip_top_lines()
697 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_mbus_config() local
698 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_g_mbus_config()
712 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_mbus_config() local
713 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_s_mbus_config()
717 return reg_clear(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000); in mt9t031_s_mbus_config()
719 return reg_set(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000); in mt9t031_s_mbus_config()
748 static int mt9t031_probe(struct i2c_client *client, in mt9t031_probe() argument
752 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_probe()
753 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); in mt9t031_probe()
757 dev_err(&client->dev, "MT9T031 driver needs platform data\n"); in mt9t031_probe()
767 mt9t031 = devm_kzalloc(&client->dev, sizeof(struct mt9t031), GFP_KERNEL); in mt9t031_probe()
771 v4l2_i2c_subdev_init(&mt9t031->subdev, client, &mt9t031_subdev_ops); in mt9t031_probe()
806 mt9t031->clk = v4l2_clk_get(&client->dev, "mclk"); in mt9t031_probe()
812 ret = mt9t031_video_probe(client); in mt9t031_probe()
822 static int mt9t031_remove(struct i2c_client *client) in mt9t031_remove() argument
824 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_remove()