Lines Matching full:sensor

70  * This table describes what should be written to the sensor register
551 * If power is on, also updates the sensor analog and digital gains.
554 static int et8ek8_set_gain(struct et8ek8_sensor *sensor, s32 gain) in et8ek8_set_gain() argument
556 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev); in et8ek8_set_gain()
582 static int et8ek8_set_test_pattern(struct et8ek8_sensor *sensor, s32 mode) in et8ek8_set_test_pattern() argument
584 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev); in et8ek8_set_test_pattern()
638 struct et8ek8_sensor *sensor = in et8ek8_set_ctrl() local
643 return et8ek8_set_gain(sensor, ctrl->val); in et8ek8_set_ctrl()
648 v4l2_get_subdevdata(&sensor->subdev); in et8ek8_set_ctrl()
655 return et8ek8_set_test_pattern(sensor, ctrl->val); in et8ek8_set_ctrl()
681 static int et8ek8_init_controls(struct et8ek8_sensor *sensor) in et8ek8_init_controls() argument
685 v4l2_ctrl_handler_init(&sensor->ctrl_handler, 4); in et8ek8_init_controls()
688 v4l2_ctrl_new_std(&sensor->ctrl_handler, &et8ek8_ctrl_ops, in et8ek8_init_controls()
692 max_rows = sensor->current_reglist->mode.max_exp; in et8ek8_init_controls()
696 sensor->exposure = in et8ek8_init_controls()
697 v4l2_ctrl_new_std(&sensor->ctrl_handler, in et8ek8_init_controls()
703 sensor->pixel_rate = in et8ek8_init_controls()
704 v4l2_ctrl_new_std(&sensor->ctrl_handler, &et8ek8_ctrl_ops, in et8ek8_init_controls()
708 v4l2_ctrl_new_std_menu_items(&sensor->ctrl_handler, in et8ek8_init_controls()
713 if (sensor->ctrl_handler.error) in et8ek8_init_controls()
714 return sensor->ctrl_handler.error; in et8ek8_init_controls()
716 sensor->subdev.ctrl_handler = &sensor->ctrl_handler; in et8ek8_init_controls()
721 static void et8ek8_update_controls(struct et8ek8_sensor *sensor) in et8ek8_update_controls() argument
724 struct et8ek8_mode *mode = &sensor->current_reglist->mode; in et8ek8_update_controls()
729 ctrl = sensor->exposure; in et8ek8_update_controls()
743 __v4l2_ctrl_s_ctrl_int64(sensor->pixel_rate, pixel_rate << S); in et8ek8_update_controls()
746 static int et8ek8_configure(struct et8ek8_sensor *sensor) in et8ek8_configure() argument
748 struct v4l2_subdev *subdev = &sensor->subdev; in et8ek8_configure()
752 rval = et8ek8_i2c_write_regs(client, sensor->current_reglist->regs); in et8ek8_configure()
756 /* Controls set while the power to the sensor is turned off are saved in et8ek8_configure()
760 rval = v4l2_ctrl_handler_setup(&sensor->ctrl_handler); in et8ek8_configure()
767 dev_err(&client->dev, "sensor configuration failed\n"); in et8ek8_configure()
772 static int et8ek8_stream_on(struct et8ek8_sensor *sensor) in et8ek8_stream_on() argument
774 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev); in et8ek8_stream_on()
779 static int et8ek8_stream_off(struct et8ek8_sensor *sensor) in et8ek8_stream_off() argument
781 struct i2c_client *client = v4l2_get_subdevdata(&sensor->subdev); in et8ek8_stream_off()
788 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_s_stream() local
792 return et8ek8_stream_off(sensor); in et8ek8_s_stream()
794 ret = et8ek8_configure(sensor); in et8ek8_s_stream()
798 return et8ek8_stream_on(sensor); in et8ek8_s_stream()
805 static int et8ek8_power_off(struct et8ek8_sensor *sensor) in et8ek8_power_off() argument
807 gpiod_set_value(sensor->reset, 0); in et8ek8_power_off()
810 clk_disable_unprepare(sensor->ext_clk); in et8ek8_power_off()
812 return regulator_disable(sensor->vana); in et8ek8_power_off()
815 static int et8ek8_power_on(struct et8ek8_sensor *sensor) in et8ek8_power_on() argument
817 struct v4l2_subdev *subdev = &sensor->subdev; in et8ek8_power_on()
822 rval = regulator_enable(sensor->vana); in et8ek8_power_on()
828 if (sensor->current_reglist) in et8ek8_power_on()
829 xclk_freq = sensor->current_reglist->mode.ext_clock; in et8ek8_power_on()
831 xclk_freq = sensor->xclk_freq; in et8ek8_power_on()
833 rval = clk_set_rate(sensor->ext_clk, xclk_freq); in et8ek8_power_on()
839 rval = clk_prepare_enable(sensor->ext_clk); in et8ek8_power_on()
850 gpiod_set_value(sensor->reset, 1); in et8ek8_power_on()
875 et8ek8_power_off(sensor); in et8ek8_power_on()
992 __et8ek8_get_pad_format(struct et8ek8_sensor *sensor, in __et8ek8_get_pad_format() argument
998 return v4l2_subdev_get_try_format(&sensor->subdev, sd_state, in __et8ek8_get_pad_format()
1001 return &sensor->format; in __et8ek8_get_pad_format()
1011 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_get_pad_format() local
1014 format = __et8ek8_get_pad_format(sensor, sd_state, fmt->pad, in et8ek8_get_pad_format()
1028 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_set_pad_format() local
1032 format = __et8ek8_get_pad_format(sensor, sd_state, fmt->pad, in et8ek8_set_pad_format()
1042 sensor->current_reglist = reglist; in et8ek8_set_pad_format()
1043 et8ek8_update_controls(sensor); in et8ek8_set_pad_format()
1052 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_get_frame_interval() local
1055 fi->interval = sensor->current_reglist->mode.timeperframe; in et8ek8_get_frame_interval()
1063 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_set_frame_interval() local
1067 sensor->current_reglist, in et8ek8_set_frame_interval()
1073 if (sensor->current_reglist->mode.ext_clock != reglist->mode.ext_clock) in et8ek8_set_frame_interval()
1076 sensor->current_reglist = reglist; in et8ek8_set_frame_interval()
1077 et8ek8_update_controls(sensor); in et8ek8_set_frame_interval()
1084 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_g_priv_mem() local
1088 u8 *ptr = sensor->priv_mem; in et8ek8_g_priv_mem()
1159 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_dev_init() local
1163 rval = et8ek8_power_on(sensor); in et8ek8_dev_init()
1175 dev_err(&client->dev, "no et8ek8 sensor detected\n"); in et8ek8_dev_init()
1179 sensor->version = (rev_h << 8) + rev_l; in et8ek8_dev_init()
1180 if (sensor->version != ET8EK8_REV_1 && sensor->version != ET8EK8_REV_2) in et8ek8_dev_init()
1183 sensor->version); in et8ek8_dev_init()
1193 sensor->current_reglist = et8ek8_reglist_find_type(&meta_reglist, in et8ek8_dev_init()
1195 if (!sensor->current_reglist) { in et8ek8_dev_init()
1203 et8ek8_reglist_to_mbus(sensor->current_reglist, &sensor->format); in et8ek8_dev_init()
1213 rval = et8ek8_stream_on(sensor); /* Needed to be able to read EEPROM */ in et8ek8_dev_init()
1219 "can not read OTP (EEPROM) memory from sensor\n"); in et8ek8_dev_init()
1220 rval = et8ek8_stream_off(sensor); in et8ek8_dev_init()
1224 rval = et8ek8_power_off(sensor); in et8ek8_dev_init()
1231 et8ek8_power_off(sensor); in et8ek8_dev_init()
1243 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in priv_mem_show() local
1249 memcpy(buf, sensor->priv_mem, ET8EK8_PRIV_MEM_SIZE); in priv_mem_show()
1262 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_registered() local
1278 rval = et8ek8_init_controls(sensor); in et8ek8_registered()
1284 __et8ek8_get_pad_format(sensor, NULL, 0, V4L2_SUBDEV_FORMAT_ACTIVE); in et8ek8_registered()
1294 static int __et8ek8_set_power(struct et8ek8_sensor *sensor, bool on) in __et8ek8_set_power() argument
1296 return on ? et8ek8_power_on(sensor) : et8ek8_power_off(sensor); in __et8ek8_set_power()
1301 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_set_power() local
1304 mutex_lock(&sensor->power_lock); in et8ek8_set_power()
1309 if (sensor->power_count == !on) { in et8ek8_set_power()
1310 ret = __et8ek8_set_power(sensor, !!on); in et8ek8_set_power()
1316 sensor->power_count += on ? 1 : -1; in et8ek8_set_power()
1317 WARN_ON(sensor->power_count < 0); in et8ek8_set_power()
1320 mutex_unlock(&sensor->power_lock); in et8ek8_set_power()
1327 struct et8ek8_sensor *sensor = to_et8ek8_sensor(sd); in et8ek8_open() local
1332 format = __et8ek8_get_pad_format(sensor, fh->state, 0, in et8ek8_open()
1380 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_suspend() local
1382 if (!sensor->power_count) in et8ek8_suspend()
1385 return __et8ek8_set_power(sensor, false); in et8ek8_suspend()
1391 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_resume() local
1393 if (!sensor->power_count) in et8ek8_resume()
1396 return __et8ek8_set_power(sensor, true); in et8ek8_resume()
1401 struct et8ek8_sensor *sensor; in et8ek8_probe() local
1405 sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL); in et8ek8_probe()
1406 if (!sensor) in et8ek8_probe()
1409 sensor->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in et8ek8_probe()
1410 if (IS_ERR(sensor->reset)) { in et8ek8_probe()
1412 return PTR_ERR(sensor->reset); in et8ek8_probe()
1415 sensor->vana = devm_regulator_get(dev, "vana"); in et8ek8_probe()
1416 if (IS_ERR(sensor->vana)) { in et8ek8_probe()
1418 return PTR_ERR(sensor->vana); in et8ek8_probe()
1421 sensor->ext_clk = devm_clk_get(dev, NULL); in et8ek8_probe()
1422 if (IS_ERR(sensor->ext_clk)) { in et8ek8_probe()
1424 return PTR_ERR(sensor->ext_clk); in et8ek8_probe()
1428 &sensor->xclk_freq); in et8ek8_probe()
1434 mutex_init(&sensor->power_lock); in et8ek8_probe()
1436 v4l2_i2c_subdev_init(&sensor->subdev, client, &et8ek8_ops); in et8ek8_probe()
1437 sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in et8ek8_probe()
1438 sensor->subdev.internal_ops = &et8ek8_internal_ops; in et8ek8_probe()
1440 sensor->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; in et8ek8_probe()
1441 sensor->pad.flags = MEDIA_PAD_FL_SOURCE; in et8ek8_probe()
1442 ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->pad); in et8ek8_probe()
1448 ret = v4l2_async_register_subdev_sensor(&sensor->subdev); in et8ek8_probe()
1457 media_entity_cleanup(&sensor->subdev.entity); in et8ek8_probe()
1459 mutex_destroy(&sensor->power_lock); in et8ek8_probe()
1466 struct et8ek8_sensor *sensor = to_et8ek8_sensor(subdev); in et8ek8_remove() local
1468 if (sensor->power_count) { in et8ek8_remove()
1470 et8ek8_power_off(sensor); in et8ek8_remove()
1471 sensor->power_count = 0; in et8ek8_remove()
1474 v4l2_device_unregister_subdev(&sensor->subdev); in et8ek8_remove()
1476 v4l2_ctrl_handler_free(&sensor->ctrl_handler); in et8ek8_remove()
1477 v4l2_async_unregister_subdev(&sensor->subdev); in et8ek8_remove()
1478 media_entity_cleanup(&sensor->subdev.entity); in et8ek8_remove()
1479 mutex_destroy(&sensor->power_lock); in et8ek8_remove()
1512 MODULE_DESCRIPTION("Toshiba ET8EK8 camera sensor driver");