Lines Matching refs:jx_f37

108 struct jx_f37 {  struct
135 #define to_jx_f37(sd) container_of(sd, struct jx_f37, subdev) argument
490 static void jx_f37_update_cur_mode_locked(struct jx_f37 *jx_f37, in jx_f37_update_cur_mode_locked() argument
495 jx_f37->cur_mode = mode; in jx_f37_update_cur_mode_locked()
497 __v4l2_ctrl_modify_range(jx_f37->hblank, h_blank, in jx_f37_update_cur_mode_locked()
500 __v4l2_ctrl_modify_range(jx_f37->vblank, vblank_def, in jx_f37_update_cur_mode_locked()
505 static int jx_f37_set_hdr_mode_locked(struct jx_f37 *jx_f37, u32 hdr_mode) in jx_f37_set_hdr_mode_locked() argument
516 jx_f37_update_cur_mode_locked(jx_f37, &supported_modes[i]); in jx_f37_set_hdr_mode_locked()
529 struct jx_f37 *jx_f37 = to_jx_f37(sd); in set_hdr_mode() local
533 mutex_lock(&jx_f37->mutex); in set_hdr_mode()
537 ret = jx_f37_set_hdr_mode_locked(jx_f37, status); in set_hdr_mode()
544 mutex_unlock(&jx_f37->mutex); in set_hdr_mode()
554 struct jx_f37 *jx_f37 = to_jx_f37(sd); in show_hdr_mode() local
556 return sprintf(buf, "%u\n", jx_f37->cur_mode->hdr_mode); in show_hdr_mode()
588 jx_f37_find_best_fit(struct jx_f37 *jx_f37, struct v4l2_subdev_format *fmt) in jx_f37_find_best_fit() argument
591 u32 cur_hdr_mode = jx_f37->cur_mode->hdr_mode; in jx_f37_find_best_fit()
615 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_set_fmt() local
618 mutex_lock(&jx_f37->mutex); in jx_f37_set_fmt()
620 mode = jx_f37_find_best_fit(jx_f37, fmt); in jx_f37_set_fmt()
629 mutex_unlock(&jx_f37->mutex); in jx_f37_set_fmt()
633 jx_f37_update_cur_mode_locked(jx_f37, mode); in jx_f37_set_fmt()
636 mutex_unlock(&jx_f37->mutex); in jx_f37_set_fmt()
645 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_get_fmt() local
646 const struct jx_f37_mode *mode = jx_f37->cur_mode; in jx_f37_get_fmt()
648 mutex_lock(&jx_f37->mutex); in jx_f37_get_fmt()
653 mutex_unlock(&jx_f37->mutex); in jx_f37_get_fmt()
666 mutex_unlock(&jx_f37->mutex); in jx_f37_get_fmt()
700 static void jx_f37_get_module_inf(struct jx_f37 *jx_f37, in jx_f37_get_module_inf() argument
705 strlcpy(inf->base.module, jx_f37->module_name, in jx_f37_get_module_inf()
707 strlcpy(inf->base.lens, jx_f37->len_name, sizeof(inf->base.lens)); in jx_f37_get_module_inf()
710 static int jx_f37_set_hdrae(struct jx_f37 *jx_f37, in jx_f37_set_hdrae() argument
713 struct i2c_client *client = jx_f37->client; in jx_f37_set_hdrae()
719 if (!jx_f37->has_init_exp && !jx_f37->streaming) { in jx_f37_set_hdrae()
720 jx_f37->init_hdrae_exp = *ae; in jx_f37_set_hdrae()
721 jx_f37->has_init_exp = true; in jx_f37_set_hdrae()
727 fh = jx_f37->vblank->cur.val + jx_f37->cur_mode->height; in jx_f37_set_hdrae()
753 if (jx_f37->cur_mode->hdr_mode == HDR_X2) { in jx_f37_set_hdrae()
800 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_ioctl() local
807 ret = jx_f37_set_hdrae(jx_f37, arg); in jx_f37_ioctl()
810 jx_f37_get_module_inf(jx_f37, (struct rkmodule_inf *)arg); in jx_f37_ioctl()
815 hdr->hdr_mode = jx_f37->cur_mode->hdr_mode; in jx_f37_ioctl()
819 w = jx_f37->cur_mode->width; in jx_f37_ioctl()
820 h = jx_f37->cur_mode->height; in jx_f37_ioctl()
825 jx_f37_update_cur_mode_locked(jx_f37, &supported_modes[i]); in jx_f37_ioctl()
830 dev_err(&jx_f37->client->dev, in jx_f37_ioctl()
925 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_g_frame_interval() local
926 const struct jx_f37_mode *mode = jx_f37->cur_mode; in jx_f37_g_frame_interval()
928 mutex_lock(&jx_f37->mutex); in jx_f37_g_frame_interval()
930 mutex_unlock(&jx_f37->mutex); in jx_f37_g_frame_interval()
938 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_g_mbus_config() local
939 const struct jx_f37_mode *mode = jx_f37->cur_mode; in jx_f37_g_mbus_config()
958 static int __jx_f37_start_stream(struct jx_f37 *jx_f37) in __jx_f37_start_stream() argument
962 ret = jx_f37_write_array(jx_f37->client, jx_f37->cur_mode->reg_list); in __jx_f37_start_stream()
968 mutex_unlock(&jx_f37->mutex); in __jx_f37_start_stream()
969 ret = v4l2_ctrl_handler_setup(&jx_f37->ctrl_handler); in __jx_f37_start_stream()
970 mutex_lock(&jx_f37->mutex); in __jx_f37_start_stream()
974 if (jx_f37->has_init_exp && jx_f37->cur_mode->hdr_mode != NO_HDR) { in __jx_f37_start_stream()
975 ret = jx_f37_ioctl(&jx_f37->subdev, PREISP_CMD_SET_HDRAE_EXP, in __jx_f37_start_stream()
976 &jx_f37->init_hdrae_exp); in __jx_f37_start_stream()
978 dev_err(&jx_f37->client->dev, in __jx_f37_start_stream()
982 jx_f37->has_init_exp = false; in __jx_f37_start_stream()
988 static int __jx_f37_stop_stream(struct jx_f37 *jx_f37) in __jx_f37_stop_stream() argument
993 ret = jx_f37_read_reg(jx_f37->client, JX_F37_REG_CTRL_MODE, &val); in __jx_f37_stop_stream()
995 dev_err(&jx_f37->client->dev, "%s: read reg failed, %d\n", in __jx_f37_stop_stream()
999 return jx_f37_write_reg(jx_f37->client, JX_F37_REG_CTRL_MODE, in __jx_f37_stop_stream()
1005 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_s_stream() local
1006 struct i2c_client *client = jx_f37->client; in jx_f37_s_stream()
1009 mutex_lock(&jx_f37->mutex); in jx_f37_s_stream()
1011 if (on == jx_f37->streaming) in jx_f37_s_stream()
1021 ret = __jx_f37_start_stream(jx_f37); in jx_f37_s_stream()
1027 dev_info(&client->dev, "hdr_mode %d\n", jx_f37->cur_mode->hdr_mode); in jx_f37_s_stream()
1029 __jx_f37_stop_stream(jx_f37); in jx_f37_s_stream()
1033 jx_f37->streaming = on; in jx_f37_s_stream()
1036 mutex_unlock(&jx_f37->mutex); in jx_f37_s_stream()
1043 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_s_power() local
1044 struct i2c_client *client = jx_f37->client; in jx_f37_s_power()
1047 mutex_lock(&jx_f37->mutex); in jx_f37_s_power()
1050 if (jx_f37->power_on == !!on) in jx_f37_s_power()
1064 __jx_f37_stop_stream(jx_f37); in jx_f37_s_power()
1065 jx_f37->power_on = true; in jx_f37_s_power()
1068 jx_f37->power_on = false; in jx_f37_s_power()
1072 mutex_unlock(&jx_f37->mutex); in jx_f37_s_power()
1077 static int __jx_f37_power_on(struct jx_f37 *jx_f37) in __jx_f37_power_on() argument
1081 struct device *dev = &jx_f37->client->dev; in __jx_f37_power_on()
1083 ret = clk_set_rate(jx_f37->xvclk, JX_F37_XVCLK_FREQ); in __jx_f37_power_on()
1088 if (clk_get_rate(jx_f37->xvclk) != JX_F37_XVCLK_FREQ) in __jx_f37_power_on()
1090 ret = clk_prepare_enable(jx_f37->xvclk); in __jx_f37_power_on()
1096 if (!IS_ERR(jx_f37->reset_gpio)) in __jx_f37_power_on()
1097 gpiod_set_value_cansleep(jx_f37->reset_gpio, 1); in __jx_f37_power_on()
1099 ret = regulator_bulk_enable(JX_F37_NUM_SUPPLIES, jx_f37->supplies); in __jx_f37_power_on()
1108 if (!IS_ERR(jx_f37->reset_gpio)) in __jx_f37_power_on()
1109 gpiod_set_value_cansleep(jx_f37->reset_gpio, 0); in __jx_f37_power_on()
1111 if (!IS_ERR(jx_f37->pwdn_gpio)) in __jx_f37_power_on()
1112 gpiod_set_value_cansleep(jx_f37->pwdn_gpio, 0); in __jx_f37_power_on()
1121 clk_disable_unprepare(jx_f37->xvclk); in __jx_f37_power_on()
1126 static void __jx_f37_power_off(struct jx_f37 *jx_f37) in __jx_f37_power_off() argument
1128 if (!IS_ERR(jx_f37->pwdn_gpio)) in __jx_f37_power_off()
1129 gpiod_set_value_cansleep(jx_f37->pwdn_gpio, 1); in __jx_f37_power_off()
1130 clk_disable_unprepare(jx_f37->xvclk); in __jx_f37_power_off()
1131 if (!IS_ERR(jx_f37->reset_gpio)) in __jx_f37_power_off()
1132 gpiod_set_value_cansleep(jx_f37->reset_gpio, 1); in __jx_f37_power_off()
1133 regulator_bulk_disable(JX_F37_NUM_SUPPLIES, jx_f37->supplies); in __jx_f37_power_off()
1140 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_runtime_resume() local
1142 return __jx_f37_power_on(jx_f37); in jx_f37_runtime_resume()
1149 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_runtime_suspend() local
1151 __jx_f37_power_off(jx_f37); in jx_f37_runtime_suspend()
1159 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_open() local
1164 mutex_lock(&jx_f37->mutex); in jx_f37_open()
1171 mutex_unlock(&jx_f37->mutex); in jx_f37_open()
1235 struct jx_f37 *jx_f37 = container_of(ctrl->handler, in jx_f37_set_ctrl() local
1236 struct jx_f37, ctrl_handler); in jx_f37_set_ctrl()
1237 struct i2c_client *client = jx_f37->client; in jx_f37_set_ctrl()
1246 max = jx_f37->cur_mode->height + ctrl->val; in jx_f37_set_ctrl()
1247 __v4l2_ctrl_modify_range(jx_f37->exposure, in jx_f37_set_ctrl()
1248 jx_f37->exposure->minimum, max, in jx_f37_set_ctrl()
1249 jx_f37->exposure->step, in jx_f37_set_ctrl()
1250 jx_f37->exposure->default_value); in jx_f37_set_ctrl()
1261 ret = jx_f37_write_reg(jx_f37->client, in jx_f37_set_ctrl()
1264 ret |= jx_f37_write_reg(jx_f37->client, in jx_f37_set_ctrl()
1270 ret |= jx_f37_write_reg(jx_f37->client, in jx_f37_set_ctrl()
1276 ret = jx_f37_read_reg(jx_f37->client, JX_F37_FLIP_MIRROR_REG, in jx_f37_set_ctrl()
1282 ret |= jx_f37_write_reg(jx_f37->client, JX_F37_FLIP_MIRROR_REG, in jx_f37_set_ctrl()
1286 ret = jx_f37_read_reg(jx_f37->client, JX_F37_FLIP_MIRROR_REG, in jx_f37_set_ctrl()
1292 ret |= jx_f37_write_reg(jx_f37->client, JX_F37_FLIP_MIRROR_REG, in jx_f37_set_ctrl()
1297 ret |= jx_f37_write_reg(jx_f37->client, JX_F37_REG_HIGH_VTS, in jx_f37_set_ctrl()
1298 JX_F37_FETCH_HIGH_BYTE_VTS((ctrl->val + jx_f37->cur_mode->height))); in jx_f37_set_ctrl()
1299 ret |= jx_f37_write_reg(jx_f37->client, JX_F37_REG_LOW_VTS, in jx_f37_set_ctrl()
1300 JX_F37_FETCH_LOW_BYTE_VTS((ctrl->val + jx_f37->cur_mode->height))); in jx_f37_set_ctrl()
1317 static int jx_f37_initialize_controls(struct jx_f37 *jx_f37) in jx_f37_initialize_controls() argument
1326 handler = &jx_f37->ctrl_handler; in jx_f37_initialize_controls()
1327 mode = jx_f37->cur_mode; in jx_f37_initialize_controls()
1331 handler->lock = &jx_f37->mutex; in jx_f37_initialize_controls()
1342 jx_f37->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in jx_f37_initialize_controls()
1344 if (jx_f37->hblank) in jx_f37_initialize_controls()
1345 jx_f37->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in jx_f37_initialize_controls()
1348 jx_f37->vblank = v4l2_ctrl_new_std(handler, &jx_f37_ctrl_ops, in jx_f37_initialize_controls()
1354 jx_f37->exposure = v4l2_ctrl_new_std(handler, &jx_f37_ctrl_ops, in jx_f37_initialize_controls()
1359 jx_f37->anal_gain = v4l2_ctrl_new_std(handler, &jx_f37_ctrl_ops, in jx_f37_initialize_controls()
1372 dev_err(&jx_f37->client->dev, in jx_f37_initialize_controls()
1377 jx_f37->subdev.ctrl_handler = handler; in jx_f37_initialize_controls()
1387 static int jx_f37_check_sensor_id(struct jx_f37 *jx_f37, in jx_f37_check_sensor_id() argument
1390 struct device *dev = &jx_f37->client->dev; in jx_f37_check_sensor_id()
1409 static int jx_f37_configure_regulators(struct jx_f37 *jx_f37) in jx_f37_configure_regulators() argument
1414 jx_f37->supplies[i].supply = jx_f37_supply_names[i]; in jx_f37_configure_regulators()
1416 return devm_regulator_bulk_get(&jx_f37->client->dev, in jx_f37_configure_regulators()
1418 jx_f37->supplies); in jx_f37_configure_regulators()
1426 struct jx_f37 *jx_f37; in jx_f37_probe() local
1437 jx_f37 = devm_kzalloc(dev, sizeof(*jx_f37), GFP_KERNEL); in jx_f37_probe()
1438 if (!jx_f37) in jx_f37_probe()
1442 &jx_f37->module_index); in jx_f37_probe()
1444 &jx_f37->module_facing); in jx_f37_probe()
1446 &jx_f37->module_name); in jx_f37_probe()
1448 &jx_f37->len_name); in jx_f37_probe()
1454 jx_f37->client = client; in jx_f37_probe()
1457 if (ret || (jx_f37_set_hdr_mode_locked(jx_f37, hdr_mode))) { in jx_f37_probe()
1458 jx_f37->cur_mode = &supported_modes[0]; in jx_f37_probe()
1462 jx_f37->xvclk = devm_clk_get(dev, "xvclk"); in jx_f37_probe()
1463 if (IS_ERR(jx_f37->xvclk)) { in jx_f37_probe()
1468 jx_f37->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in jx_f37_probe()
1469 if (IS_ERR(jx_f37->reset_gpio)) in jx_f37_probe()
1472 jx_f37->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in jx_f37_probe()
1473 if (IS_ERR(jx_f37->pwdn_gpio)) in jx_f37_probe()
1476 ret = jx_f37_configure_regulators(jx_f37); in jx_f37_probe()
1482 mutex_init(&jx_f37->mutex); in jx_f37_probe()
1484 sd = &jx_f37->subdev; in jx_f37_probe()
1486 ret = jx_f37_initialize_controls(jx_f37); in jx_f37_probe()
1490 ret = __jx_f37_power_on(jx_f37); in jx_f37_probe()
1494 ret = jx_f37_check_sensor_id(jx_f37, client); in jx_f37_probe()
1504 jx_f37->pad.flags = MEDIA_PAD_FL_SOURCE; in jx_f37_probe()
1506 ret = media_entity_pads_init(&sd->entity, 1, &jx_f37->pad); in jx_f37_probe()
1512 if (strcmp(jx_f37->module_facing, "back") == 0) in jx_f37_probe()
1518 jx_f37->module_index, facing, in jx_f37_probe()
1543 __jx_f37_power_off(jx_f37); in jx_f37_probe()
1545 v4l2_ctrl_handler_free(&jx_f37->ctrl_handler); in jx_f37_probe()
1547 mutex_destroy(&jx_f37->mutex); in jx_f37_probe()
1557 struct jx_f37 *jx_f37 = to_jx_f37(sd); in jx_f37_remove() local
1563 v4l2_ctrl_handler_free(&jx_f37->ctrl_handler); in jx_f37_remove()
1564 mutex_destroy(&jx_f37->mutex); in jx_f37_remove()
1568 __jx_f37_power_off(jx_f37); in jx_f37_remove()