Lines Matching refs:mt9m001
24 * mt9m001 i2c address 0x5d
27 /* mt9m001 selected register addresses */
88 struct mt9m001 {
110 static struct mt9m001 *to_mt9m001(const struct i2c_client *client)
112 return container_of(i2c_get_clientdata(client), struct mt9m001, subdev);
189 struct mt9m001 *mt9m001 = to_mt9m001(client);
198 { MT9M001_COLUMN_START, mt9m001->rect.left },
199 { MT9M001_ROW_START, mt9m001->rect.top },
200 { MT9M001_WINDOW_WIDTH, mt9m001->rect.width - 1 },
202 mt9m001->rect.height + mt9m001->y_skip_top - 1 },
211 struct mt9m001 *mt9m001 = to_mt9m001(client);
214 mutex_lock(&mt9m001->mutex);
216 if (mt9m001->streaming == enable)
228 ret = __v4l2_ctrl_handler_setup(&mt9m001->hdl);
242 mt9m001->streaming = enable;
244 mutex_unlock(&mt9m001->mutex);
250 mutex_unlock(&mt9m001->mutex);
260 struct mt9m001 *mt9m001 = to_mt9m001(client);
267 if (mt9m001->fmts == mt9m001_colour_fmts)
288 mt9m001->total_h = rect.height + mt9m001->y_skip_top +
291 mt9m001->rect = rect;
301 struct mt9m001 *mt9m001 = to_mt9m001(client);
314 sel->r = mt9m001->rect;
326 struct mt9m001 *mt9m001 = to_mt9m001(client);
338 mf->width = mt9m001->rect.width;
339 mf->height = mt9m001->rect.height;
340 mf->code = mt9m001->fmt->code;
341 mf->colorspace = mt9m001->fmt->colorspace;
355 struct mt9m001 *mt9m001 = to_mt9m001(client);
359 .r.left = mt9m001->rect.left,
360 .r.top = mt9m001->rect.top,
369 mf->width = mt9m001->rect.width;
370 mf->height = mt9m001->rect.height;
371 mt9m001->fmt = fmt;
384 struct mt9m001 *mt9m001 = to_mt9m001(client);
392 &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top,
393 MT9M001_MAX_HEIGHT + mt9m001->y_skip_top, 0, 0);
395 if (mt9m001->fmts == mt9m001_colour_fmts)
398 fmt = mt9m001_find_datafmt(mf->code, mt9m001->fmts,
399 mt9m001->num_fmts);
401 fmt = mt9m001->fmt;
453 struct mt9m001 *mt9m001 = to_mt9m001(client);
456 ret = clk_prepare_enable(mt9m001->clk);
460 if (mt9m001->standby_gpio) {
461 gpiod_set_value_cansleep(mt9m001->standby_gpio, 0);
465 if (mt9m001->reset_gpio) {
466 gpiod_set_value_cansleep(mt9m001->reset_gpio, 1);
468 gpiod_set_value_cansleep(mt9m001->reset_gpio, 0);
478 struct mt9m001 *mt9m001 = to_mt9m001(client);
480 gpiod_set_value_cansleep(mt9m001->standby_gpio, 1);
481 clk_disable_unprepare(mt9m001->clk);
488 struct mt9m001 *mt9m001 = container_of(ctrl->handler,
489 struct mt9m001, hdl);
494 min = mt9m001->exposure->minimum;
495 max = mt9m001->exposure->maximum;
496 mt9m001->exposure->val =
497 (524 + (mt9m001->total_h - 1) * (max - min)) / 1048 + min;
505 struct mt9m001 *mt9m001 = container_of(ctrl->handler,
506 struct mt9m001, hdl);
507 struct v4l2_subdev *sd = &mt9m001->subdev;
509 struct v4l2_ctrl *exp = mt9m001->exposure;
564 mt9m001->total_h = mt9m001->rect.height +
565 mt9m001->y_skip_top + MT9M001_DEFAULT_VBLANK;
567 mt9m001->total_h);
586 struct mt9m001 *mt9m001 = to_mt9m001(client);
601 mt9m001->fmts = mt9m001_colour_fmts;
602 mt9m001->num_fmts = ARRAY_SIZE(mt9m001_colour_fmts);
605 mt9m001->fmts = mt9m001_monochrome_fmts;
606 mt9m001->num_fmts = ARRAY_SIZE(mt9m001_monochrome_fmts);
615 mt9m001->fmt = &mt9m001->fmts[0];
627 ret = v4l2_ctrl_handler_setup(&mt9m001->hdl);
636 struct mt9m001 *mt9m001 = to_mt9m001(client);
638 *lines = mt9m001->y_skip_top;
662 struct mt9m001 *mt9m001 = to_mt9m001(client);
668 try_fmt->code = mt9m001->fmts[0].code;
669 try_fmt->colorspace = mt9m001->fmts[0].colorspace;
683 struct mt9m001 *mt9m001 = to_mt9m001(client);
685 if (code->pad || code->index >= mt9m001->num_fmts)
688 code->code = mt9m001->fmts[code->index].code;
732 struct mt9m001 *mt9m001;
742 mt9m001 = devm_kzalloc(&client->dev, sizeof(*mt9m001), GFP_KERNEL);
743 if (!mt9m001)
746 mt9m001->clk = devm_clk_get(&client->dev, NULL);
747 if (IS_ERR(mt9m001->clk))
748 return PTR_ERR(mt9m001->clk);
750 mt9m001->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
752 if (IS_ERR(mt9m001->standby_gpio))
753 return PTR_ERR(mt9m001->standby_gpio);
755 mt9m001->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
757 if (IS_ERR(mt9m001->reset_gpio))
758 return PTR_ERR(mt9m001->reset_gpio);
760 v4l2_i2c_subdev_init(&mt9m001->subdev, client, &mt9m001_subdev_ops);
761 mt9m001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
763 v4l2_ctrl_handler_init(&mt9m001->hdl, 4);
764 v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
766 v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
768 mt9m001->exposure = v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
774 mt9m001->autoexposure = v4l2_ctrl_new_std_menu(&mt9m001->hdl,
777 mt9m001->subdev.ctrl_handler = &mt9m001->hdl;
778 if (mt9m001->hdl.error)
779 return mt9m001->hdl.error;
781 v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure,
784 mutex_init(&mt9m001->mutex);
785 mt9m001->hdl.lock = &mt9m001->mutex;
788 mt9m001->y_skip_top = 0;
789 mt9m001->rect.left = MT9M001_COLUMN_SKIP;
790 mt9m001->rect.top = MT9M001_ROW_SKIP;
791 mt9m001->rect.width = MT9M001_MAX_WIDTH;
792 mt9m001->rect.height = MT9M001_MAX_HEIGHT;
805 mt9m001->pad.flags = MEDIA_PAD_FL_SOURCE;
806 mt9m001->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
807 ret = media_entity_pads_init(&mt9m001->subdev.entity, 1, &mt9m001->pad);
811 ret = v4l2_async_register_subdev(&mt9m001->subdev);
820 media_entity_cleanup(&mt9m001->subdev.entity);
827 v4l2_ctrl_handler_free(&mt9m001->hdl);
828 mutex_destroy(&mt9m001->mutex);
835 struct mt9m001 *mt9m001 = to_mt9m001(client);
839 v4l2_async_unregister_subdev(&mt9m001->subdev);
840 media_entity_cleanup(&mt9m001->subdev.entity);
847 v4l2_ctrl_handler_free(&mt9m001->hdl);
848 mutex_destroy(&mt9m001->mutex);
854 { "mt9m001", 0 },
864 { .compatible = "onnn,mt9m001", },
871 .name = "mt9m001",