Lines Matching refs:jx_h65
106 struct jx_h65 { struct
131 #define to_jx_h65(sd) container_of(sd, struct jx_h65, subdev) argument
490 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_set_fmt() local
494 mutex_lock(&jx_h65->mutex); in jx_h65_set_fmt()
505 mutex_unlock(&jx_h65->mutex); in jx_h65_set_fmt()
509 jx_h65->cur_mode = mode; in jx_h65_set_fmt()
511 __v4l2_ctrl_modify_range(jx_h65->hblank, h_blank, in jx_h65_set_fmt()
514 __v4l2_ctrl_modify_range(jx_h65->vblank, vblank_def, in jx_h65_set_fmt()
519 mutex_unlock(&jx_h65->mutex); in jx_h65_set_fmt()
528 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_get_fmt() local
529 const struct jx_h65_mode *mode = jx_h65->cur_mode; in jx_h65_get_fmt()
531 mutex_lock(&jx_h65->mutex); in jx_h65_get_fmt()
536 mutex_unlock(&jx_h65->mutex); in jx_h65_get_fmt()
545 mutex_unlock(&jx_h65->mutex); in jx_h65_get_fmt()
579 static int jx_h65_enable_test_pattern(struct jx_h65 *jx_h65, u32 pattern) in jx_h65_enable_test_pattern() argument
588 return jx_h65_write_reg(jx_h65->client, JX_H65_REG_TEST_PATTERN, val); in jx_h65_enable_test_pattern()
591 static void jx_h65_get_module_inf(struct jx_h65 *jx_h65, in jx_h65_get_module_inf() argument
596 strlcpy(inf->base.module, jx_h65->module_name, in jx_h65_get_module_inf()
598 strlcpy(inf->base.lens, jx_h65->len_name, sizeof(inf->base.lens)); in jx_h65_get_module_inf()
603 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_ioctl() local
609 jx_h65_get_module_inf(jx_h65, (struct rkmodule_inf *)arg); in jx_h65_ioctl()
616 ret = jx_h65_write_reg(jx_h65->client, JX_H65_REG_CTRL_MODE, in jx_h65_ioctl()
619 ret = jx_h65_write_reg(jx_h65->client, JX_H65_REG_CTRL_MODE, in jx_h65_ioctl()
682 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_g_frame_interval() local
683 const struct jx_h65_mode *mode = jx_h65->cur_mode; in jx_h65_g_frame_interval()
685 mutex_lock(&jx_h65->mutex); in jx_h65_g_frame_interval()
687 mutex_unlock(&jx_h65->mutex); in jx_h65_g_frame_interval()
692 static int __jx_h65_start_stream(struct jx_h65 *jx_h65) in __jx_h65_start_stream() argument
694 return jx_h65_write_reg(jx_h65->client, JX_H65_REG_CTRL_MODE, in __jx_h65_start_stream()
698 static int __jx_h65_stop_stream(struct jx_h65 *jx_h65) in __jx_h65_stop_stream() argument
700 return jx_h65_write_reg(jx_h65->client, JX_H65_REG_CTRL_MODE, in __jx_h65_stop_stream()
706 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_s_stream() local
707 struct i2c_client *client = jx_h65->client; in jx_h65_s_stream()
710 mutex_lock(&jx_h65->mutex); in jx_h65_s_stream()
712 if (on == jx_h65->streaming) in jx_h65_s_stream()
722 ret = __jx_h65_start_stream(jx_h65); in jx_h65_s_stream()
729 __jx_h65_stop_stream(jx_h65); in jx_h65_s_stream()
733 jx_h65->streaming = on; in jx_h65_s_stream()
736 mutex_unlock(&jx_h65->mutex); in jx_h65_s_stream()
743 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_s_power() local
744 struct i2c_client *client = jx_h65->client; in jx_h65_s_power()
747 mutex_lock(&jx_h65->mutex); in jx_h65_s_power()
750 if (jx_h65->power_on == !!on) in jx_h65_s_power()
760 ret = jx_h65_write_array(jx_h65->client, in jx_h65_s_power()
761 jx_h65->cur_mode->reg_list); in jx_h65_s_power()
769 __jx_h65_stop_stream(jx_h65); in jx_h65_s_power()
771 mutex_unlock(&jx_h65->mutex); in jx_h65_s_power()
773 ret = v4l2_ctrl_handler_setup(&jx_h65->ctrl_handler); in jx_h65_s_power()
776 mutex_lock(&jx_h65->mutex); in jx_h65_s_power()
778 jx_h65->power_on = true; in jx_h65_s_power()
781 jx_h65->power_on = false; in jx_h65_s_power()
785 mutex_unlock(&jx_h65->mutex); in jx_h65_s_power()
790 static int __jx_h65_power_on(struct jx_h65 *jx_h65) in __jx_h65_power_on() argument
794 struct device *dev = &jx_h65->client->dev; in __jx_h65_power_on()
796 ret = clk_set_rate(jx_h65->xvclk, JX_H65_XVCLK_FREQ); in __jx_h65_power_on()
801 if (clk_get_rate(jx_h65->xvclk) != JX_H65_XVCLK_FREQ) in __jx_h65_power_on()
803 ret = clk_prepare_enable(jx_h65->xvclk); in __jx_h65_power_on()
809 if (!IS_ERR(jx_h65->reset_gpio)) in __jx_h65_power_on()
810 gpiod_set_value_cansleep(jx_h65->reset_gpio, 1); in __jx_h65_power_on()
812 ret = regulator_bulk_enable(JX_H65_NUM_SUPPLIES, jx_h65->supplies); in __jx_h65_power_on()
821 if (!IS_ERR(jx_h65->reset_gpio)) in __jx_h65_power_on()
822 gpiod_set_value_cansleep(jx_h65->reset_gpio, 0); in __jx_h65_power_on()
824 if (!IS_ERR(jx_h65->pwdn_gpio)) in __jx_h65_power_on()
825 gpiod_set_value_cansleep(jx_h65->pwdn_gpio, 0); in __jx_h65_power_on()
834 clk_disable_unprepare(jx_h65->xvclk); in __jx_h65_power_on()
839 static void __jx_h65_power_off(struct jx_h65 *jx_h65) in __jx_h65_power_off() argument
841 if (!IS_ERR(jx_h65->pwdn_gpio)) in __jx_h65_power_off()
842 gpiod_set_value_cansleep(jx_h65->pwdn_gpio, 1); in __jx_h65_power_off()
843 clk_disable_unprepare(jx_h65->xvclk); in __jx_h65_power_off()
844 if (!IS_ERR(jx_h65->reset_gpio)) in __jx_h65_power_off()
845 gpiod_set_value_cansleep(jx_h65->reset_gpio, 1); in __jx_h65_power_off()
846 regulator_bulk_disable(JX_H65_NUM_SUPPLIES, jx_h65->supplies); in __jx_h65_power_off()
853 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_runtime_resume() local
855 return __jx_h65_power_on(jx_h65); in jx_h65_runtime_resume()
862 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_runtime_suspend() local
864 __jx_h65_power_off(jx_h65); in jx_h65_runtime_suspend()
872 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_open() local
877 mutex_lock(&jx_h65->mutex); in jx_h65_open()
884 mutex_unlock(&jx_h65->mutex); in jx_h65_open()
961 struct jx_h65 *jx_h65 = container_of(ctrl->handler, in jx_h65_set_ctrl() local
962 struct jx_h65, ctrl_handler); in jx_h65_set_ctrl()
963 struct i2c_client *client = jx_h65->client; in jx_h65_set_ctrl()
971 max = jx_h65->cur_mode->height + ctrl->val; in jx_h65_set_ctrl()
972 __v4l2_ctrl_modify_range(jx_h65->exposure, in jx_h65_set_ctrl()
973 jx_h65->exposure->minimum, max, in jx_h65_set_ctrl()
974 jx_h65->exposure->step, in jx_h65_set_ctrl()
975 jx_h65->exposure->default_value); in jx_h65_set_ctrl()
986 ret = jx_h65_write_reg(jx_h65->client, in jx_h65_set_ctrl()
989 ret |= jx_h65_write_reg(jx_h65->client, in jx_h65_set_ctrl()
995 ret |= jx_h65_write_reg(jx_h65->client, in jx_h65_set_ctrl()
1002 ret |= jx_h65_write_reg(jx_h65->client, JX_H65_REG_HIGH_VTS, in jx_h65_set_ctrl()
1003 JX_H65_FETCH_HIGH_BYTE_VTS((ctrl->val + jx_h65->cur_mode->height))); in jx_h65_set_ctrl()
1004 ret |= jx_h65_write_reg(jx_h65->client, JX_H65_REG_LOW_VTS, in jx_h65_set_ctrl()
1005 JX_H65_FETCH_LOW_BYTE_VTS((ctrl->val + jx_h65->cur_mode->height))); in jx_h65_set_ctrl()
1008 ret = jx_h65_enable_test_pattern(jx_h65, ctrl->val); in jx_h65_set_ctrl()
1025 static int jx_h65_initialize_controls(struct jx_h65 *jx_h65) in jx_h65_initialize_controls() argument
1034 handler = &jx_h65->ctrl_handler; in jx_h65_initialize_controls()
1035 mode = jx_h65->cur_mode; in jx_h65_initialize_controls()
1039 handler->lock = &jx_h65->mutex; in jx_h65_initialize_controls()
1050 jx_h65->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in jx_h65_initialize_controls()
1052 if (jx_h65->hblank) in jx_h65_initialize_controls()
1053 jx_h65->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in jx_h65_initialize_controls()
1056 jx_h65->vblank = v4l2_ctrl_new_std(handler, &jx_h65_ctrl_ops, in jx_h65_initialize_controls()
1062 jx_h65->exposure = v4l2_ctrl_new_std(handler, &jx_h65_ctrl_ops, in jx_h65_initialize_controls()
1067 jx_h65->anal_gain = v4l2_ctrl_new_std(handler, &jx_h65_ctrl_ops, in jx_h65_initialize_controls()
1073 jx_h65->digi_gain = v4l2_ctrl_new_std(handler, &jx_h65_ctrl_ops, in jx_h65_initialize_controls()
1078 jx_h65->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in jx_h65_initialize_controls()
1085 dev_err(&jx_h65->client->dev, in jx_h65_initialize_controls()
1090 jx_h65->subdev.ctrl_handler = handler; in jx_h65_initialize_controls()
1100 static int jx_h65_check_sensor_id(struct jx_h65 *jx_h65, in jx_h65_check_sensor_id() argument
1103 struct device *dev = &jx_h65->client->dev; in jx_h65_check_sensor_id()
1122 static int jx_h65_configure_regulators(struct jx_h65 *jx_h65) in jx_h65_configure_regulators() argument
1127 jx_h65->supplies[i].supply = jx_h65_supply_names[i]; in jx_h65_configure_regulators()
1129 return devm_regulator_bulk_get(&jx_h65->client->dev, in jx_h65_configure_regulators()
1131 jx_h65->supplies); in jx_h65_configure_regulators()
1139 struct jx_h65 *jx_h65; in jx_h65_probe() local
1149 jx_h65 = devm_kzalloc(dev, sizeof(*jx_h65), GFP_KERNEL); in jx_h65_probe()
1150 if (!jx_h65) in jx_h65_probe()
1154 &jx_h65->module_index); in jx_h65_probe()
1156 &jx_h65->module_facing); in jx_h65_probe()
1158 &jx_h65->module_name); in jx_h65_probe()
1160 &jx_h65->len_name); in jx_h65_probe()
1166 jx_h65->client = client; in jx_h65_probe()
1167 jx_h65->cur_mode = &supported_modes[0]; in jx_h65_probe()
1169 jx_h65->xvclk = devm_clk_get(dev, "xvclk"); in jx_h65_probe()
1170 if (IS_ERR(jx_h65->xvclk)) { in jx_h65_probe()
1175 jx_h65->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in jx_h65_probe()
1176 if (IS_ERR(jx_h65->reset_gpio)) in jx_h65_probe()
1179 jx_h65->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in jx_h65_probe()
1180 if (IS_ERR(jx_h65->pwdn_gpio)) in jx_h65_probe()
1183 ret = jx_h65_configure_regulators(jx_h65); in jx_h65_probe()
1189 mutex_init(&jx_h65->mutex); in jx_h65_probe()
1191 sd = &jx_h65->subdev; in jx_h65_probe()
1193 ret = jx_h65_initialize_controls(jx_h65); in jx_h65_probe()
1197 ret = __jx_h65_power_on(jx_h65); in jx_h65_probe()
1201 ret = jx_h65_check_sensor_id(jx_h65, client); in jx_h65_probe()
1211 jx_h65->pad.flags = MEDIA_PAD_FL_SOURCE; in jx_h65_probe()
1213 ret = media_entity_pads_init(&sd->entity, 1, &jx_h65->pad); in jx_h65_probe()
1219 if (strcmp(jx_h65->module_facing, "back") == 0) in jx_h65_probe()
1225 jx_h65->module_index, facing, in jx_h65_probe()
1245 __jx_h65_power_off(jx_h65); in jx_h65_probe()
1247 v4l2_ctrl_handler_free(&jx_h65->ctrl_handler); in jx_h65_probe()
1249 mutex_destroy(&jx_h65->mutex); in jx_h65_probe()
1257 struct jx_h65 *jx_h65 = to_jx_h65(sd); in jx_h65_remove() local
1263 v4l2_ctrl_handler_free(&jx_h65->ctrl_handler); in jx_h65_remove()
1264 mutex_destroy(&jx_h65->mutex); in jx_h65_remove()
1268 __jx_h65_power_off(jx_h65); in jx_h65_remove()