Lines Matching refs:jx_h62
112 struct jx_h62 { struct
144 #define to_jx_h62(sd) container_of(sd, struct jx_h62, subdev) argument
386 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_set_fmt() local
390 mutex_lock(&jx_h62->mutex); in jx_h62_set_fmt()
401 mutex_unlock(&jx_h62->mutex); in jx_h62_set_fmt()
405 jx_h62->cur_mode = mode; in jx_h62_set_fmt()
407 __v4l2_ctrl_modify_range(jx_h62->hblank, h_blank, in jx_h62_set_fmt()
410 __v4l2_ctrl_modify_range(jx_h62->vblank, vblank_def, in jx_h62_set_fmt()
415 mutex_unlock(&jx_h62->mutex); in jx_h62_set_fmt()
424 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_get_fmt() local
425 const struct jx_h62_mode *mode = jx_h62->cur_mode; in jx_h62_get_fmt()
427 mutex_lock(&jx_h62->mutex); in jx_h62_get_fmt()
432 mutex_unlock(&jx_h62->mutex); in jx_h62_get_fmt()
441 mutex_unlock(&jx_h62->mutex); in jx_h62_get_fmt()
475 static int jx_h62_enable_test_pattern(struct jx_h62 *jx_h62, u32 pattern) in jx_h62_enable_test_pattern() argument
484 return jx_h62_write_reg(jx_h62->client, JX_H62_REG_TEST_PATTERN, val); in jx_h62_enable_test_pattern()
487 static void jx_h62_get_module_inf(struct jx_h62 *jx_h62, in jx_h62_get_module_inf() argument
492 strlcpy(inf->base.module, jx_h62->module_name, in jx_h62_get_module_inf()
494 strlcpy(inf->base.lens, jx_h62->len_name, sizeof(inf->base.lens)); in jx_h62_get_module_inf()
499 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_ioctl() local
505 jx_h62_get_module_inf(jx_h62, (struct rkmodule_inf *)arg); in jx_h62_ioctl()
512 ret = jx_h62_write_reg(jx_h62->client, JX_H62_REG_CTRL_MODE, in jx_h62_ioctl()
515 ret = jx_h62_write_reg(jx_h62->client, JX_H62_REG_CTRL_MODE, in jx_h62_ioctl()
578 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_g_frame_interval() local
579 const struct jx_h62_mode *mode = jx_h62->cur_mode; in jx_h62_g_frame_interval()
581 mutex_lock(&jx_h62->mutex); in jx_h62_g_frame_interval()
583 mutex_unlock(&jx_h62->mutex); in jx_h62_g_frame_interval()
588 static int __jx_h62_start_stream(struct jx_h62 *jx_h62) in __jx_h62_start_stream() argument
590 return jx_h62_write_reg(jx_h62->client, JX_H62_REG_CTRL_MODE, in __jx_h62_start_stream()
594 static int __jx_h62_stop_stream(struct jx_h62 *jx_h62) in __jx_h62_stop_stream() argument
596 return jx_h62_write_reg(jx_h62->client, JX_H62_REG_CTRL_MODE, in __jx_h62_stop_stream()
602 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_s_stream() local
603 struct i2c_client *client = jx_h62->client; in jx_h62_s_stream()
606 mutex_lock(&jx_h62->mutex); in jx_h62_s_stream()
608 if (on == jx_h62->streaming) in jx_h62_s_stream()
612 jx_h62->cur_mode->width, in jx_h62_s_stream()
613 jx_h62->cur_mode->height, in jx_h62_s_stream()
614 DIV_ROUND_CLOSEST(jx_h62->cur_mode->max_fps.denominator, in jx_h62_s_stream()
615 jx_h62->cur_mode->max_fps.numerator)); in jx_h62_s_stream()
624 ret = __jx_h62_start_stream(jx_h62); in jx_h62_s_stream()
631 __jx_h62_stop_stream(jx_h62); in jx_h62_s_stream()
635 jx_h62->streaming = on; in jx_h62_s_stream()
638 mutex_unlock(&jx_h62->mutex); in jx_h62_s_stream()
645 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_s_power() local
646 struct i2c_client *client = jx_h62->client; in jx_h62_s_power()
649 mutex_lock(&jx_h62->mutex); in jx_h62_s_power()
652 if (jx_h62->power_on == !!on) in jx_h62_s_power()
662 ret = jx_h62_write_array(jx_h62->client, in jx_h62_s_power()
663 jx_h62->cur_mode->reg_list); in jx_h62_s_power()
671 __jx_h62_stop_stream(jx_h62); in jx_h62_s_power()
673 mutex_unlock(&jx_h62->mutex); in jx_h62_s_power()
675 ret = v4l2_ctrl_handler_setup(&jx_h62->ctrl_handler); in jx_h62_s_power()
678 mutex_lock(&jx_h62->mutex); in jx_h62_s_power()
680 jx_h62->power_on = true; in jx_h62_s_power()
683 jx_h62->power_on = false; in jx_h62_s_power()
687 mutex_unlock(&jx_h62->mutex); in jx_h62_s_power()
692 static int __jx_h62_power_on(struct jx_h62 *jx_h62) in __jx_h62_power_on() argument
696 struct device *dev = &jx_h62->client->dev; in __jx_h62_power_on()
698 ret = clk_set_rate(jx_h62->xvclk, JX_H62_XVCLK_FREQ); in __jx_h62_power_on()
703 if (clk_get_rate(jx_h62->xvclk) != JX_H62_XVCLK_FREQ) in __jx_h62_power_on()
705 ret = clk_prepare_enable(jx_h62->xvclk); in __jx_h62_power_on()
711 if (!IS_ERR(jx_h62->reset_gpio)) in __jx_h62_power_on()
712 gpiod_set_value_cansleep(jx_h62->reset_gpio, 1); in __jx_h62_power_on()
714 ret = regulator_bulk_enable(JX_H62_NUM_SUPPLIES, jx_h62->supplies); in __jx_h62_power_on()
723 if (!IS_ERR(jx_h62->reset_gpio)) in __jx_h62_power_on()
724 gpiod_set_value_cansleep(jx_h62->reset_gpio, 0); in __jx_h62_power_on()
726 if (!IS_ERR(jx_h62->pwdn_gpio)) in __jx_h62_power_on()
727 gpiod_set_value_cansleep(jx_h62->pwdn_gpio, 0); in __jx_h62_power_on()
736 clk_disable_unprepare(jx_h62->xvclk); in __jx_h62_power_on()
741 static void __jx_h62_power_off(struct jx_h62 *jx_h62) in __jx_h62_power_off() argument
743 if (!IS_ERR(jx_h62->pwdn_gpio)) in __jx_h62_power_off()
744 gpiod_set_value_cansleep(jx_h62->pwdn_gpio, 1); in __jx_h62_power_off()
745 clk_disable_unprepare(jx_h62->xvclk); in __jx_h62_power_off()
746 if (!IS_ERR(jx_h62->reset_gpio)) in __jx_h62_power_off()
747 gpiod_set_value_cansleep(jx_h62->reset_gpio, 1); in __jx_h62_power_off()
748 regulator_bulk_disable(JX_H62_NUM_SUPPLIES, jx_h62->supplies); in __jx_h62_power_off()
755 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_runtime_resume() local
757 return __jx_h62_power_on(jx_h62); in jx_h62_runtime_resume()
764 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_runtime_suspend() local
766 __jx_h62_power_off(jx_h62); in jx_h62_runtime_suspend()
774 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_open() local
779 mutex_lock(&jx_h62->mutex); in jx_h62_open()
786 mutex_unlock(&jx_h62->mutex); in jx_h62_open()
860 static int jx_h62_set_ctrl_gain(struct jx_h62 *jx_h62, u32 a_gain) in jx_h62_set_ctrl_gain() argument
866 if ( a_gain != jx_h62->old_gain) { in jx_h62_set_ctrl_gain()
880 ret = jx_h62_write_reg(jx_h62->client, in jx_h62_set_ctrl_gain()
882 jx_h62->old_gain = a_gain; in jx_h62_set_ctrl_gain()
889 struct jx_h62 *jx_h62 = container_of(ctrl->handler, in jx_h62_set_ctrl() local
890 struct jx_h62, ctrl_handler); in jx_h62_set_ctrl()
891 struct i2c_client *client = jx_h62->client; in jx_h62_set_ctrl()
899 max = jx_h62->cur_mode->height + ctrl->val; in jx_h62_set_ctrl()
900 __v4l2_ctrl_modify_range(jx_h62->exposure, in jx_h62_set_ctrl()
901 jx_h62->exposure->minimum, max, in jx_h62_set_ctrl()
902 jx_h62->exposure->step, in jx_h62_set_ctrl()
903 jx_h62->exposure->default_value); in jx_h62_set_ctrl()
914 ret = jx_h62_write_reg(jx_h62->client, in jx_h62_set_ctrl()
917 ret |= jx_h62_write_reg(jx_h62->client, in jx_h62_set_ctrl()
923 ret = jx_h62_set_ctrl_gain(jx_h62, ctrl->val); in jx_h62_set_ctrl()
929 ret |= jx_h62_write_reg(jx_h62->client, JX_H62_REG_HIGH_VTS, in jx_h62_set_ctrl()
930 JX_H62_FETCH_HIGH_BYTE_VTS((ctrl->val + jx_h62->cur_mode->height))); in jx_h62_set_ctrl()
931 ret |= jx_h62_write_reg(jx_h62->client, JX_H62_REG_LOW_VTS, in jx_h62_set_ctrl()
932 JX_H62_FETCH_LOW_BYTE_VTS((ctrl->val + jx_h62->cur_mode->height))); in jx_h62_set_ctrl()
935 ret = jx_h62_enable_test_pattern(jx_h62, ctrl->val); in jx_h62_set_ctrl()
952 static int jx_h62_initialize_controls(struct jx_h62 *jx_h62) in jx_h62_initialize_controls() argument
961 handler = &jx_h62->ctrl_handler; in jx_h62_initialize_controls()
962 mode = jx_h62->cur_mode; in jx_h62_initialize_controls()
967 handler->lock = &jx_h62->mutex; in jx_h62_initialize_controls()
976 0, jx_h62->pixel_rate, 1, jx_h62->pixel_rate); in jx_h62_initialize_controls()
979 jx_h62->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in jx_h62_initialize_controls()
982 if (jx_h62->hblank) in jx_h62_initialize_controls()
983 jx_h62->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in jx_h62_initialize_controls()
986 jx_h62->vblank = v4l2_ctrl_new_std(handler, &jx_h62_ctrl_ops, in jx_h62_initialize_controls()
993 jx_h62->exposure = v4l2_ctrl_new_std(handler, &jx_h62_ctrl_ops, in jx_h62_initialize_controls()
998 jx_h62->anal_gain = v4l2_ctrl_new_std(handler, &jx_h62_ctrl_ops, in jx_h62_initialize_controls()
1004 jx_h62->digi_gain = v4l2_ctrl_new_std(handler, &jx_h62_ctrl_ops, in jx_h62_initialize_controls()
1009 jx_h62->test_pattern = v4l2_ctrl_new_std_menu_items(handler, in jx_h62_initialize_controls()
1016 dev_err(&jx_h62->client->dev, in jx_h62_initialize_controls()
1021 jx_h62->subdev.ctrl_handler = handler; in jx_h62_initialize_controls()
1022 jx_h62->old_gain = ANALOG_GAIN_DEFAULT; in jx_h62_initialize_controls()
1032 static int jx_h62_check_sensor_id(struct jx_h62 *jx_h62, in jx_h62_check_sensor_id() argument
1035 struct device *dev = &jx_h62->client->dev; in jx_h62_check_sensor_id()
1054 static int jx_h62_configure_regulators(struct jx_h62 *jx_h62) in jx_h62_configure_regulators() argument
1059 jx_h62->supplies[i].supply = jx_h62_supply_names[i]; in jx_h62_configure_regulators()
1061 return devm_regulator_bulk_get(&jx_h62->client->dev, in jx_h62_configure_regulators()
1063 jx_h62->supplies); in jx_h62_configure_regulators()
1066 static int jx_h62_parse_of(struct jx_h62 *jx_h62) in jx_h62_parse_of() argument
1068 struct device *dev = &jx_h62->client->dev; in jx_h62_parse_of()
1085 jx_h62->lane_num = rval; in jx_h62_parse_of()
1086 if (1 == jx_h62->lane_num) { in jx_h62_parse_of()
1088 jx_h62->pixel_rate = MIPI_FREQ * 2U * jx_h62->lane_num / 10U; in jx_h62_parse_of()
1090 jx_h62->lane_num, jx_h62->pixel_rate); in jx_h62_parse_of()
1092 dev_err(dev, "unsupported lane_num(%d)\n", jx_h62->lane_num); in jx_h62_parse_of()
1104 struct jx_h62 *jx_h62; in jx_h62_probe() local
1114 jx_h62 = devm_kzalloc(dev, sizeof(*jx_h62), GFP_KERNEL); in jx_h62_probe()
1115 if (!jx_h62) in jx_h62_probe()
1119 &jx_h62->module_index); in jx_h62_probe()
1121 &jx_h62->module_facing); in jx_h62_probe()
1123 &jx_h62->module_name); in jx_h62_probe()
1125 &jx_h62->len_name); in jx_h62_probe()
1131 jx_h62->client = client; in jx_h62_probe()
1132 jx_h62->cur_mode = &supported_modes[0]; in jx_h62_probe()
1134 jx_h62->xvclk = devm_clk_get(dev, "xvclk"); in jx_h62_probe()
1135 if (IS_ERR(jx_h62->xvclk)) { in jx_h62_probe()
1140 jx_h62->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in jx_h62_probe()
1141 if (IS_ERR(jx_h62->reset_gpio)) in jx_h62_probe()
1144 jx_h62->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in jx_h62_probe()
1145 if (IS_ERR(jx_h62->pwdn_gpio)) in jx_h62_probe()
1148 ret = jx_h62_configure_regulators(jx_h62); in jx_h62_probe()
1153 ret = jx_h62_parse_of(jx_h62); in jx_h62_probe()
1157 jx_h62->pinctrl = devm_pinctrl_get(dev); in jx_h62_probe()
1158 if (!IS_ERR(jx_h62->pinctrl)) { in jx_h62_probe()
1159 jx_h62->pins_default = in jx_h62_probe()
1160 pinctrl_lookup_state(jx_h62->pinctrl, in jx_h62_probe()
1162 if (IS_ERR(jx_h62->pins_default)) in jx_h62_probe()
1165 jx_h62->pins_sleep = in jx_h62_probe()
1166 pinctrl_lookup_state(jx_h62->pinctrl, in jx_h62_probe()
1168 if (IS_ERR(jx_h62->pins_sleep)) in jx_h62_probe()
1172 mutex_init(&jx_h62->mutex); in jx_h62_probe()
1174 sd = &jx_h62->subdev; in jx_h62_probe()
1176 ret = jx_h62_initialize_controls(jx_h62); in jx_h62_probe()
1180 ret = __jx_h62_power_on(jx_h62); in jx_h62_probe()
1184 ret = jx_h62_check_sensor_id(jx_h62, client); in jx_h62_probe()
1194 jx_h62->pad.flags = MEDIA_PAD_FL_SOURCE; in jx_h62_probe()
1196 ret = media_entity_pads_init(&sd->entity, 1, &jx_h62->pad); in jx_h62_probe()
1202 if (strcmp(jx_h62->module_facing, "back") == 0) in jx_h62_probe()
1208 jx_h62->module_index, facing, in jx_h62_probe()
1228 __jx_h62_power_off(jx_h62); in jx_h62_probe()
1230 v4l2_ctrl_handler_free(&jx_h62->ctrl_handler); in jx_h62_probe()
1232 mutex_destroy(&jx_h62->mutex); in jx_h62_probe()
1240 struct jx_h62 *jx_h62 = to_jx_h62(sd); in jx_h62_remove() local
1246 v4l2_ctrl_handler_free(&jx_h62->ctrl_handler); in jx_h62_remove()
1247 mutex_destroy(&jx_h62->mutex); in jx_h62_remove()
1251 __jx_h62_power_off(jx_h62); in jx_h62_remove()