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()
343 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_fmt() local
344 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_g_fmt()
358 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_fmt() local
359 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_s_fmt()
374 return mt9t031_set_params(client, &rect, xskip, yskip); in mt9t031_s_fmt()
398 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_register() local
404 reg->val = reg_read(client, reg->reg); in mt9t031_g_register()
415 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_register() local
420 if (reg_write(client, reg->reg, reg->val) < 0) in mt9t031_s_register()
451 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_ctrl() local
458 data = reg_set(client, MT9T031_READ_MODE_2, 0x8000); in mt9t031_s_ctrl()
460 data = reg_clear(client, MT9T031_READ_MODE_2, 0x8000); in mt9t031_s_ctrl()
466 data = reg_set(client, MT9T031_READ_MODE_2, 0x4000); in mt9t031_s_ctrl()
468 data = reg_clear(client, MT9T031_READ_MODE_2, 0x4000); in mt9t031_s_ctrl()
479 dev_dbg(&client->dev, "Setting gain %d\n", data); in mt9t031_s_ctrl()
480 data = reg_write(client, MT9T031_GLOBAL_GAIN, data); in mt9t031_s_ctrl()
499 dev_dbg(&client->dev, "Set gain from 0x%x to 0x%x\n", in mt9t031_s_ctrl()
500 reg_read(client, MT9T031_GLOBAL_GAIN), data); in mt9t031_s_ctrl()
501 data = reg_write(client, MT9T031_GLOBAL_GAIN, data); in mt9t031_s_ctrl()
514 get_shutter(client, &old); in mt9t031_s_ctrl()
515 dev_dbg(&client->dev, "Set shutter from %u to %u\n", in mt9t031_s_ctrl()
517 if (set_shutter(client, shutter) < 0) in mt9t031_s_ctrl()
524 if (set_shutter(client, mt9t031->total_h) < 0) in mt9t031_s_ctrl()
553 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_runtime_resume() local
554 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_runtime_resume()
562 ret = reg_write(client, MT9T031_COLUMN_ADDRESS_MODE, in mt9t031_runtime_resume()
567 ret = reg_write(client, MT9T031_ROW_ADDRESS_MODE, in mt9t031_runtime_resume()
587 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_power() local
588 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_s_power()
589 struct video_device *vdev = soc_camera_i2c_to_vdev(client); in mt9t031_s_power()
590 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_s_power()
594 ret = soc_camera_power_on(&client->dev, ssdd, mt9t031->clk); in mt9t031_s_power()
603 soc_camera_power_off(&client->dev, ssdd, mt9t031->clk); in mt9t031_s_power()
613 static int mt9t031_video_probe(struct i2c_client *client) in mt9t031_video_probe() argument
615 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_video_probe()
623 ret = mt9t031_idle(client); in mt9t031_video_probe()
625 dev_err(&client->dev, "Failed to initialise the camera\n"); in mt9t031_video_probe()
630 data = reg_read(client, MT9T031_CHIP_VERSION); in mt9t031_video_probe()
636 dev_err(&client->dev, in mt9t031_video_probe()
642 dev_info(&client->dev, "Detected a MT9T031 chip ID %x\n", data); in mt9t031_video_probe()
654 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_skip_top_lines() local
655 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_g_skip_top_lines()
688 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_g_mbus_config() local
689 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_g_mbus_config()
703 struct i2c_client *client = v4l2_get_subdevdata(sd); in mt9t031_s_mbus_config() local
704 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_s_mbus_config()
708 return reg_clear(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000); in mt9t031_s_mbus_config()
710 return reg_set(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000); in mt9t031_s_mbus_config()
736 static int mt9t031_probe(struct i2c_client *client, in mt9t031_probe() argument
740 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); in mt9t031_probe()
741 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); in mt9t031_probe()
745 dev_err(&client->dev, "MT9T031 driver needs platform data\n"); in mt9t031_probe()
755 mt9t031 = devm_kzalloc(&client->dev, sizeof(struct mt9t031), GFP_KERNEL); in mt9t031_probe()
759 v4l2_i2c_subdev_init(&mt9t031->subdev, client, &mt9t031_subdev_ops); in mt9t031_probe()
794 mt9t031->clk = v4l2_clk_get(&client->dev, "mclk"); in mt9t031_probe()
800 ret = mt9t031_video_probe(client); in mt9t031_probe()
810 static int mt9t031_remove(struct i2c_client *client) in mt9t031_remove() argument
812 struct mt9t031 *mt9t031 = to_mt9t031(client); in mt9t031_remove()