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);
251 mutex_unlock(&mt9m001->mutex);
261 struct mt9m001 *mt9m001 = to_mt9m001(client);
268 if (mt9m001->fmts == mt9m001_colour_fmts)
289 mt9m001->total_h = rect.height + mt9m001->y_skip_top +
292 mt9m001->rect = rect;
302 struct mt9m001 *mt9m001 = to_mt9m001(client);
315 sel->r = mt9m001->rect;
327 struct mt9m001 *mt9m001 = to_mt9m001(client);
339 mf->width = mt9m001->rect.width;
340 mf->height = mt9m001->rect.height;
341 mf->code = mt9m001->fmt->code;
342 mf->colorspace = mt9m001->fmt->colorspace;
356 struct mt9m001 *mt9m001 = to_mt9m001(client);
360 .r.left = mt9m001->rect.left,
361 .r.top = mt9m001->rect.top,
370 mf->width = mt9m001->rect.width;
371 mf->height = mt9m001->rect.height;
372 mt9m001->fmt = fmt;
385 struct mt9m001 *mt9m001 = to_mt9m001(client);
393 &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top,
394 MT9M001_MAX_HEIGHT + mt9m001->y_skip_top, 0, 0);
396 if (mt9m001->fmts == mt9m001_colour_fmts)
399 fmt = mt9m001_find_datafmt(mf->code, mt9m001->fmts,
400 mt9m001->num_fmts);
402 fmt = mt9m001->fmt;
454 struct mt9m001 *mt9m001 = to_mt9m001(client);
457 ret = clk_prepare_enable(mt9m001->clk);
461 if (mt9m001->standby_gpio) {
462 gpiod_set_value_cansleep(mt9m001->standby_gpio, 0);
466 if (mt9m001->reset_gpio) {
467 gpiod_set_value_cansleep(mt9m001->reset_gpio, 1);
469 gpiod_set_value_cansleep(mt9m001->reset_gpio, 0);
479 struct mt9m001 *mt9m001 = to_mt9m001(client);
481 gpiod_set_value_cansleep(mt9m001->standby_gpio, 1);
482 clk_disable_unprepare(mt9m001->clk);
489 struct mt9m001 *mt9m001 = container_of(ctrl->handler,
490 struct mt9m001, hdl);
495 min = mt9m001->exposure->minimum;
496 max = mt9m001->exposure->maximum;
497 mt9m001->exposure->val =
498 (524 + (mt9m001->total_h - 1) * (max - min)) / 1048 + min;
506 struct mt9m001 *mt9m001 = container_of(ctrl->handler,
507 struct mt9m001, hdl);
508 struct v4l2_subdev *sd = &mt9m001->subdev;
510 struct v4l2_ctrl *exp = mt9m001->exposure;
565 mt9m001->total_h = mt9m001->rect.height +
566 mt9m001->y_skip_top + MT9M001_DEFAULT_VBLANK;
568 mt9m001->total_h);
587 struct mt9m001 *mt9m001 = to_mt9m001(client);
602 mt9m001->fmts = mt9m001_colour_fmts;
603 mt9m001->num_fmts = ARRAY_SIZE(mt9m001_colour_fmts);
606 mt9m001->fmts = mt9m001_monochrome_fmts;
607 mt9m001->num_fmts = ARRAY_SIZE(mt9m001_monochrome_fmts);
616 mt9m001->fmt = &mt9m001->fmts[0];
628 ret = v4l2_ctrl_handler_setup(&mt9m001->hdl);
637 struct mt9m001 *mt9m001 = to_mt9m001(client);
639 *lines = mt9m001->y_skip_top;
663 struct mt9m001 *mt9m001 = to_mt9m001(client);
669 try_fmt->code = mt9m001->fmts[0].code;
670 try_fmt->colorspace = mt9m001->fmts[0].colorspace;
684 struct mt9m001 *mt9m001 = to_mt9m001(client);
686 if (code->pad || code->index >= mt9m001->num_fmts)
689 code->code = mt9m001->fmts[code->index].code;
735 struct mt9m001 *mt9m001;
745 mt9m001 = devm_kzalloc(&client->dev, sizeof(*mt9m001), GFP_KERNEL);
746 if (!mt9m001)
749 mt9m001->clk = devm_clk_get(&client->dev, NULL);
750 if (IS_ERR(mt9m001->clk))
751 return PTR_ERR(mt9m001->clk);
753 mt9m001->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
755 if (IS_ERR(mt9m001->standby_gpio))
756 return PTR_ERR(mt9m001->standby_gpio);
758 mt9m001->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
760 if (IS_ERR(mt9m001->reset_gpio))
761 return PTR_ERR(mt9m001->reset_gpio);
763 v4l2_i2c_subdev_init(&mt9m001->subdev, client, &mt9m001_subdev_ops);
764 mt9m001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
766 v4l2_ctrl_handler_init(&mt9m001->hdl, 4);
767 v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
769 v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
771 mt9m001->exposure = v4l2_ctrl_new_std(&mt9m001->hdl, &mt9m001_ctrl_ops,
777 mt9m001->autoexposure = v4l2_ctrl_new_std_menu(&mt9m001->hdl,
780 mt9m001->subdev.ctrl_handler = &mt9m001->hdl;
781 if (mt9m001->hdl.error)
782 return mt9m001->hdl.error;
784 v4l2_ctrl_auto_cluster(2, &mt9m001->autoexposure,
787 mutex_init(&mt9m001->mutex);
788 mt9m001->hdl.lock = &mt9m001->mutex;
791 mt9m001->y_skip_top = 0;
792 mt9m001->rect.left = MT9M001_COLUMN_SKIP;
793 mt9m001->rect.top = MT9M001_ROW_SKIP;
794 mt9m001->rect.width = MT9M001_MAX_WIDTH;
795 mt9m001->rect.height = MT9M001_MAX_HEIGHT;
808 mt9m001->pad.flags = MEDIA_PAD_FL_SOURCE;
809 mt9m001->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
810 ret = media_entity_pads_init(&mt9m001->subdev.entity, 1, &mt9m001->pad);
814 ret = v4l2_async_register_subdev(&mt9m001->subdev);
823 media_entity_cleanup(&mt9m001->subdev.entity);
830 v4l2_ctrl_handler_free(&mt9m001->hdl);
831 mutex_destroy(&mt9m001->mutex);
838 struct mt9m001 *mt9m001 = to_mt9m001(client);
846 v4l2_async_unregister_subdev(&mt9m001->subdev);
847 media_entity_cleanup(&mt9m001->subdev.entity);
854 v4l2_ctrl_handler_free(&mt9m001->hdl);
855 mutex_destroy(&mt9m001->mutex);
859 { "mt9m001", 0 },
869 { .compatible = "onnn,mt9m001", },
876 .name = "mt9m001",