Lines Matching refs:mt9t001
115 struct mt9t001 { struct
135 static inline struct mt9t001 *to_mt9t001(struct v4l2_subdev *sd) in to_mt9t001() argument
137 return container_of(sd, struct mt9t001, subdev); in to_mt9t001()
150 static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear, in mt9t001_set_output_control() argument
153 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in mt9t001_set_output_control()
154 u16 value = (mt9t001->output_control & ~clear) | set; in mt9t001_set_output_control()
157 if (value == mt9t001->output_control) in mt9t001_set_output_control()
164 mt9t001->output_control = value; in mt9t001_set_output_control()
168 static int mt9t001_reset(struct mt9t001 *mt9t001) in mt9t001_reset() argument
170 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in mt9t001_reset()
182 mt9t001->output_control = MT9T001_OUTPUT_CONTROL_DEF; in mt9t001_reset()
184 return mt9t001_set_output_control(mt9t001, in mt9t001_reset()
189 static int mt9t001_power_on(struct mt9t001 *mt9t001) in mt9t001_power_on() argument
194 ret = regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), in mt9t001_power_on()
195 mt9t001->regulators); in mt9t001_power_on()
200 ret = clk_prepare_enable(mt9t001->clk); in mt9t001_power_on()
202 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), in mt9t001_power_on()
203 mt9t001->regulators); in mt9t001_power_on()
208 static void mt9t001_power_off(struct mt9t001 *mt9t001) in mt9t001_power_off() argument
210 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), in mt9t001_power_off()
211 mt9t001->regulators); in mt9t001_power_off()
213 clk_disable_unprepare(mt9t001->clk); in mt9t001_power_off()
216 static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on) in __mt9t001_set_power() argument
218 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in __mt9t001_set_power()
222 mt9t001_power_off(mt9t001); in __mt9t001_set_power()
226 ret = mt9t001_power_on(mt9t001); in __mt9t001_set_power()
230 ret = mt9t001_reset(mt9t001); in __mt9t001_set_power()
236 ret = v4l2_ctrl_handler_setup(&mt9t001->ctrls); in __mt9t001_set_power()
245 mt9t001_power_off(mt9t001); in __mt9t001_set_power()
255 __mt9t001_get_pad_format(struct mt9t001 *mt9t001, struct v4l2_subdev_pad_config *cfg, in __mt9t001_get_pad_format() argument
260 return v4l2_subdev_get_try_format(&mt9t001->subdev, cfg, pad); in __mt9t001_get_pad_format()
262 return &mt9t001->format; in __mt9t001_get_pad_format()
269 __mt9t001_get_pad_crop(struct mt9t001 *mt9t001, struct v4l2_subdev_pad_config *cfg, in __mt9t001_get_pad_crop() argument
274 return v4l2_subdev_get_try_crop(&mt9t001->subdev, cfg, pad); in __mt9t001_get_pad_crop()
276 return &mt9t001->crop; in __mt9t001_get_pad_crop()
287 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_s_stream() local
288 struct v4l2_mbus_framefmt *format = &mt9t001->format; in mt9t001_s_stream()
289 struct v4l2_rect *crop = &mt9t001->crop; in mt9t001_s_stream()
295 return mt9t001_set_output_control(mt9t001, mode, 0); in mt9t001_s_stream()
334 return mt9t001_set_output_control(mt9t001, 0, mode); in mt9t001_s_stream()
367 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_get_format() local
369 format->format = *__mt9t001_get_pad_format(mt9t001, cfg, format->pad, in mt9t001_get_format()
378 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_set_format() local
386 __crop = __mt9t001_get_pad_crop(mt9t001, cfg, format->pad, in mt9t001_set_format()
402 __format = __mt9t001_get_pad_format(mt9t001, cfg, format->pad, in mt9t001_set_format()
416 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_get_selection() local
421 sel->r = *__mt9t001_get_pad_crop(mt9t001, cfg, sel->pad, sel->which); in mt9t001_get_selection()
429 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_set_selection() local
458 __crop = __mt9t001_get_pad_crop(mt9t001, cfg, sel->pad, sel->which); in mt9t001_set_selection()
464 __format = __mt9t001_get_pad_format(mt9t001, cfg, sel->pad, in mt9t001_set_selection()
518 static int mt9t001_ctrl_freeze(struct mt9t001 *mt9t001, bool freeze) in mt9t001_ctrl_freeze() argument
520 return mt9t001_set_output_control(mt9t001, in mt9t001_ctrl_freeze()
532 struct mt9t001 *mt9t001 = in mt9t001_s_ctrl() local
533 container_of(ctrl->handler, struct mt9t001, ctrls); in mt9t001_s_ctrl()
534 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); in mt9t001_s_ctrl()
550 struct v4l2_ctrl *gain = mt9t001->gains[i]; in mt9t001_s_ctrl()
557 ret = mt9t001_ctrl_freeze(mt9t001, true); in mt9t001_s_ctrl()
564 struct v4l2_ctrl *gain = mt9t001->gains[i]; in mt9t001_s_ctrl()
572 mt9t001_ctrl_freeze(mt9t001, false); in mt9t001_s_ctrl()
579 ret = mt9t001_ctrl_freeze(mt9t001, false); in mt9t001_s_ctrl()
596 return mt9t001_set_output_control(mt9t001, in mt9t001_s_ctrl()
610 mt9t001->black_level = value; in mt9t001_s_ctrl()
631 mt9t001->black_level); in mt9t001_s_ctrl()
740 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_set_power() local
743 mutex_lock(&mt9t001->power_lock); in mt9t001_set_power()
748 if (mt9t001->power_count == !on) { in mt9t001_set_power()
749 ret = __mt9t001_set_power(mt9t001, !!on); in mt9t001_set_power()
755 mt9t001->power_count += on ? 1 : -1; in mt9t001_set_power()
756 WARN_ON(mt9t001->power_count < 0); in mt9t001_set_power()
759 mutex_unlock(&mt9t001->power_lock); in mt9t001_set_power()
770 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_registered() local
774 ret = mt9t001_power_on(mt9t001); in mt9t001_registered()
782 mt9t001_power_off(mt9t001); in mt9t001_registered()
855 struct mt9t001 *mt9t001; in mt9t001_probe() local
871 mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL); in mt9t001_probe()
872 if (!mt9t001) in mt9t001_probe()
875 mutex_init(&mt9t001->power_lock); in mt9t001_probe()
876 mt9t001->output_control = MT9T001_OUTPUT_CONTROL_DEF; in mt9t001_probe()
878 mt9t001->regulators[0].supply = "vdd"; in mt9t001_probe()
879 mt9t001->regulators[1].supply = "vaa"; in mt9t001_probe()
881 ret = devm_regulator_bulk_get(&client->dev, 2, mt9t001->regulators); in mt9t001_probe()
887 mt9t001->clk = devm_clk_get(&client->dev, NULL); in mt9t001_probe()
888 if (IS_ERR(mt9t001->clk)) { in mt9t001_probe()
890 return PTR_ERR(mt9t001->clk); in mt9t001_probe()
893 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + in mt9t001_probe()
896 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
900 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
902 v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
905 v4l2_ctrl_new_std_menu_items(&mt9t001->ctrls, &mt9t001_ctrl_ops, in mt9t001_probe()
911 v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL); in mt9t001_probe()
914 mt9t001->gains[i] = v4l2_ctrl_new_custom(&mt9t001->ctrls, in mt9t001_probe()
917 v4l2_ctrl_cluster(ARRAY_SIZE(mt9t001_gains), mt9t001->gains); in mt9t001_probe()
919 mt9t001->subdev.ctrl_handler = &mt9t001->ctrls; in mt9t001_probe()
921 if (mt9t001->ctrls.error) { in mt9t001_probe()
923 __func__, mt9t001->ctrls.error); in mt9t001_probe()
928 mt9t001->crop.left = MT9T001_COLUMN_START_DEF; in mt9t001_probe()
929 mt9t001->crop.top = MT9T001_ROW_START_DEF; in mt9t001_probe()
930 mt9t001->crop.width = MT9T001_WINDOW_WIDTH_DEF + 1; in mt9t001_probe()
931 mt9t001->crop.height = MT9T001_WINDOW_HEIGHT_DEF + 1; in mt9t001_probe()
933 mt9t001->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; in mt9t001_probe()
934 mt9t001->format.width = MT9T001_WINDOW_WIDTH_DEF + 1; in mt9t001_probe()
935 mt9t001->format.height = MT9T001_WINDOW_HEIGHT_DEF + 1; in mt9t001_probe()
936 mt9t001->format.field = V4L2_FIELD_NONE; in mt9t001_probe()
937 mt9t001->format.colorspace = V4L2_COLORSPACE_SRGB; in mt9t001_probe()
939 v4l2_i2c_subdev_init(&mt9t001->subdev, client, &mt9t001_subdev_ops); in mt9t001_probe()
940 mt9t001->subdev.internal_ops = &mt9t001_subdev_internal_ops; in mt9t001_probe()
941 mt9t001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in mt9t001_probe()
943 mt9t001->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; in mt9t001_probe()
944 mt9t001->pad.flags = MEDIA_PAD_FL_SOURCE; in mt9t001_probe()
945 ret = media_entity_pads_init(&mt9t001->subdev.entity, 1, &mt9t001->pad); in mt9t001_probe()
949 v4l2_ctrl_handler_free(&mt9t001->ctrls); in mt9t001_probe()
950 media_entity_cleanup(&mt9t001->subdev.entity); in mt9t001_probe()
959 struct mt9t001 *mt9t001 = to_mt9t001(subdev); in mt9t001_remove() local
961 v4l2_ctrl_handler_free(&mt9t001->ctrls); in mt9t001_remove()