Lines Matching refs:mt9t001

118 struct mt9t001 {  struct
138 static inline struct mt9t001 *to_mt9t001(struct v4l2_subdev *sd) in to_mt9t001() argument
140 return container_of(sd, struct mt9t001, subdev); in to_mt9t001()
153 static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear, in mt9t001_set_output_control() argument
156 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in mt9t001_set_output_control()
157 u16 value = (mt9t001->output_control & ~clear) | set; in mt9t001_set_output_control()
160 if (value == mt9t001->output_control) in mt9t001_set_output_control()
167 mt9t001->output_control = value; in mt9t001_set_output_control()
171 static int mt9t001_reset(struct mt9t001 *mt9t001) in mt9t001_reset() argument
173 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in mt9t001_reset()
185 mt9t001->output_control = MT9T001_OUTPUT_CONTROL_DEF; in mt9t001_reset()
187 return mt9t001_set_output_control(mt9t001, in mt9t001_reset()
192 static int mt9t001_power_on(struct mt9t001 *mt9t001) in mt9t001_power_on() argument
197 ret = regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), in mt9t001_power_on()
198 mt9t001->regulators); in mt9t001_power_on()
203 ret = clk_prepare_enable(mt9t001->clk); in mt9t001_power_on()
205 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), in mt9t001_power_on()
206 mt9t001->regulators); in mt9t001_power_on()
211 static void mt9t001_power_off(struct mt9t001 *mt9t001) in mt9t001_power_off() argument
213 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), in mt9t001_power_off()
214 mt9t001->regulators); in mt9t001_power_off()
216 clk_disable_unprepare(mt9t001->clk); in mt9t001_power_off()
219 static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on) in __mt9t001_set_power() argument
221 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in __mt9t001_set_power()
225 mt9t001_power_off(mt9t001); in __mt9t001_set_power()
229 ret = mt9t001_power_on(mt9t001); in __mt9t001_set_power()
233 ret = mt9t001_reset(mt9t001); in __mt9t001_set_power()
239 return v4l2_ctrl_handler_setup(&mt9t001->ctrls); in __mt9t001_set_power()
247 __mt9t001_get_pad_format(struct mt9t001 *mt9t001, struct v4l2_subdev_pad_config *cfg, in __mt9t001_get_pad_format() argument
252 return v4l2_subdev_get_try_format(&mt9t001->subdev, cfg, pad); in __mt9t001_get_pad_format()
254 return &mt9t001->format; in __mt9t001_get_pad_format()
261 __mt9t001_get_pad_crop(struct mt9t001 *mt9t001, struct v4l2_subdev_pad_config *cfg, in __mt9t001_get_pad_crop() argument
266 return v4l2_subdev_get_try_crop(&mt9t001->subdev, cfg, pad); in __mt9t001_get_pad_crop()
268 return &mt9t001->crop; in __mt9t001_get_pad_crop()
279 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_s_stream() local
280 struct v4l2_mbus_framefmt *format = &mt9t001->format; in mt9t001_s_stream()
281 struct v4l2_rect *crop = &mt9t001->crop; in mt9t001_s_stream()
287 return mt9t001_set_output_control(mt9t001, mode, 0); in mt9t001_s_stream()
326 return mt9t001_set_output_control(mt9t001, 0, mode); in mt9t001_s_stream()
359 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_get_format() local
361 format->format = *__mt9t001_get_pad_format(mt9t001, cfg, format->pad, in mt9t001_get_format()
370 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_set_format() local
378 __crop = __mt9t001_get_pad_crop(mt9t001, cfg, format->pad, in mt9t001_set_format()
394 __format = __mt9t001_get_pad_format(mt9t001, cfg, format->pad, in mt9t001_set_format()
408 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_get_selection() local
413 sel->r = *__mt9t001_get_pad_crop(mt9t001, cfg, sel->pad, sel->which); in mt9t001_get_selection()
421 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_set_selection() local
450 __crop = __mt9t001_get_pad_crop(mt9t001, cfg, sel->pad, sel->which); in mt9t001_set_selection()
456 __format = __mt9t001_get_pad_format(mt9t001, cfg, sel->pad, in mt9t001_set_selection()
510 static int mt9t001_ctrl_freeze(struct mt9t001 *mt9t001, bool freeze) in mt9t001_ctrl_freeze() argument
512 return mt9t001_set_output_control(mt9t001, in mt9t001_ctrl_freeze()
524 struct mt9t001 *mt9t001 = in mt9t001_s_ctrl() local
525 container_of(ctrl->handler, struct mt9t001, ctrls); in mt9t001_s_ctrl()
526 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in mt9t001_s_ctrl()
542 struct v4l2_ctrl *gain = mt9t001->gains[i]; in mt9t001_s_ctrl()
549 ret = mt9t001_ctrl_freeze(mt9t001, true); in mt9t001_s_ctrl()
556 struct v4l2_ctrl *gain = mt9t001->gains[i]; in mt9t001_s_ctrl()
564 mt9t001_ctrl_freeze(mt9t001, false); in mt9t001_s_ctrl()
571 ret = mt9t001_ctrl_freeze(mt9t001, false); in mt9t001_s_ctrl()
588 return mt9t001_set_output_control(mt9t001, in mt9t001_s_ctrl()
602 mt9t001->black_level = value; in mt9t001_s_ctrl()
623 mt9t001->black_level); in mt9t001_s_ctrl()
732 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_set_power() local
735 mutex_lock(&mt9t001->power_lock); in mt9t001_set_power()
740 if (mt9t001->power_count == !on) { in mt9t001_set_power()
741 ret = __mt9t001_set_power(mt9t001, !!on); in mt9t001_set_power()
747 mt9t001->power_count += on ? 1 : -1; in mt9t001_set_power()
748 WARN_ON(mt9t001->power_count < 0); in mt9t001_set_power()
751 mutex_unlock(&mt9t001->power_lock); in mt9t001_set_power()
762 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_registered() local
766 ret = mt9t001_power_on(mt9t001); in mt9t001_registered()
774 mt9t001_power_off(mt9t001); in mt9t001_registered()
847 struct mt9t001 *mt9t001; in mt9t001_probe() local
863 mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL); in mt9t001_probe()
864 if (!mt9t001) in mt9t001_probe()
867 mutex_init(&mt9t001->power_lock); in mt9t001_probe()
868 mt9t001->output_control = MT9T001_OUTPUT_CONTROL_DEF; in mt9t001_probe()
870 mt9t001->regulators[0].supply = "vdd"; in mt9t001_probe()
871 mt9t001->regulators[1].supply = "vaa"; in mt9t001_probe()
873 ret = devm_regulator_bulk_get(&client->dev, 2, mt9t001->regulators); in mt9t001_probe()
879 mt9t001->clk = devm_clk_get(&client->dev, NULL); in mt9t001_probe()
880 if (IS_ERR(mt9t001->clk)) { in mt9t001_probe()
882 return PTR_ERR(mt9t001->clk); in mt9t001_probe()
885 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + in mt9t001_probe()
888 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
892 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
894 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
897 v4l2_ctrl_new_std_menu_items(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
903 v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL); in mt9t001_probe()
906 mt9t001->gains[i] = v4l2_ctrl_new_custom(&mt9t001->ctrls, in mt9t001_probe()
909 v4l2_ctrl_cluster(ARRAY_SIZE(mt9t001_gains), mt9t001->gains); in mt9t001_probe()
911 mt9t001->subdev.ctrl_handler = &mt9t001->ctrls; in mt9t001_probe()
913 if (mt9t001->ctrls.error) { in mt9t001_probe()
915 __func__, mt9t001->ctrls.error); in mt9t001_probe()
920 mt9t001->crop.left = MT9T001_COLUMN_START_DEF; in mt9t001_probe()
921 mt9t001->crop.top = MT9T001_ROW_START_DEF; in mt9t001_probe()
922 mt9t001->crop.width = MT9T001_WINDOW_WIDTH_DEF + 1; in mt9t001_probe()
923 mt9t001->crop.height = MT9T001_WINDOW_HEIGHT_DEF + 1; in mt9t001_probe()
925 mt9t001->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; in mt9t001_probe()
926 mt9t001->format.width = MT9T001_WINDOW_WIDTH_DEF + 1; in mt9t001_probe()
927 mt9t001->format.height = MT9T001_WINDOW_HEIGHT_DEF + 1; in mt9t001_probe()
928 mt9t001->format.field = V4L2_FIELD_NONE; in mt9t001_probe()
929 mt9t001->format.colorspace = V4L2_COLORSPACE_SRGB; in mt9t001_probe()
931 v4l2_i2c_subdev_init(&mt9t001->subdev, client, &mt9t001_subdev_ops); in mt9t001_probe()
932 mt9t001->subdev.internal_ops = &mt9t001_subdev_internal_ops; in mt9t001_probe()
933 mt9t001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in mt9t001_probe()
935 mt9t001->pad.flags = MEDIA_PAD_FL_SOURCE; in mt9t001_probe()
936 ret = media_entity_init(&mt9t001->subdev.entity, 1, &mt9t001->pad, 0); in mt9t001_probe()
940 v4l2_ctrl_handler_free(&mt9t001->ctrls); in mt9t001_probe()
941 media_entity_cleanup(&mt9t001->subdev.entity); in mt9t001_probe()
950 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_remove() local
952 v4l2_ctrl_handler_free(&mt9t001->ctrls); in mt9t001_remove()