Lines Matching refs:thcv244
91 struct thcv244 { struct
127 #define to_thcv244(sd) container_of(sd, struct thcv244, subdev) argument
470 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_set_fmt() local
473 mutex_lock(&thcv244->mutex); in thcv244_set_fmt()
484 mutex_unlock(&thcv244->mutex); in thcv244_set_fmt()
488 if (thcv244->streaming) { in thcv244_set_fmt()
489 mutex_unlock(&thcv244->mutex); in thcv244_set_fmt()
494 mutex_unlock(&thcv244->mutex); in thcv244_set_fmt()
503 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_get_fmt() local
504 const struct thcv244_mode *mode = thcv244->cur_mode; in thcv244_get_fmt()
506 mutex_lock(&thcv244->mutex); in thcv244_get_fmt()
511 mutex_unlock(&thcv244->mutex); in thcv244_get_fmt()
520 mutex_unlock(&thcv244->mutex); in thcv244_get_fmt()
557 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_g_frame_interval() local
558 const struct thcv244_mode *mode = thcv244->cur_mode; in thcv244_g_frame_interval()
560 mutex_lock(&thcv244->mutex); in thcv244_g_frame_interval()
562 mutex_unlock(&thcv244->mutex); in thcv244_g_frame_interval()
567 static void thcv244_get_module_inf(struct thcv244 *thcv244, in thcv244_get_module_inf() argument
572 strscpy(inf->base.module, thcv244->module_name, in thcv244_get_module_inf()
574 strscpy(inf->base.lens, thcv244->len_name, sizeof(inf->base.lens)); in thcv244_get_module_inf()
577 static void thcv244_get_vicap_rst_inf(struct thcv244 *thcv244, in thcv244_get_vicap_rst_inf() argument
580 struct i2c_client *client = thcv244->client; in thcv244_get_vicap_rst_inf()
582 rst_info->is_reset = thcv244->hot_plug; in thcv244_get_vicap_rst_inf()
583 thcv244->hot_plug = false; in thcv244_get_vicap_rst_inf()
590 static void thcv244_set_vicap_rst_inf(struct thcv244 *thcv244, in thcv244_set_vicap_rst_inf() argument
593 thcv244->is_reset = rst_info.is_reset; in thcv244_set_vicap_rst_inf()
598 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_ioctl() local
604 thcv244_get_module_inf(thcv244, (struct rkmodule_inf *)arg); in thcv244_ioctl()
611 ret = thine_write_reg(thcv244->client, THCV244_ADDR, in thcv244_ioctl()
616 ret = thine_write_reg(thcv244->client, THCV244_ADDR, in thcv244_ioctl()
622 thcv244_get_vicap_rst_inf(thcv244, in thcv244_ioctl()
626 thcv244_set_vicap_rst_inf(thcv244, in thcv244_ioctl()
723 static int thcv244_thcv241_init(struct thcv244 *thcv244) in thcv244_thcv241_init() argument
725 struct device *dev = &thcv244->client->dev; in thcv244_thcv241_init()
728 ret = thcv244_write_array(thcv244->client, thcv244_global_init_table); in thcv244_thcv241_init()
729 ret |= thine_write_reg(thcv244->client, THCV241_ADDR, 0x00fe, in thcv244_thcv241_init()
731 ret |= thine_write_reg(thcv244->client, THCV244_ADDR, 0x0032, in thcv244_thcv241_init()
733 ret |= thcv241_write_array(thcv244->client, thcv241_init_table); in thcv244_thcv241_init()
734 ret |= thcv244_write_array(thcv244->client, thcv244_1080p30_init_table); in thcv244_thcv241_init()
735 ret |= thine_write_reg(thcv244->client, THCV244_ADDR, 0x0032, in thcv244_thcv241_init()
737 ret |= thine_write_reg(thcv244->client, THCV241_ADDR, 0xfe, in thcv244_thcv241_init()
739 ret |= thine_write_reg(thcv244->client, THCV241_ADDR, 0x3e, in thcv244_thcv241_init()
742 ret |= thine_write_reg(thcv244->client, THCV241_ADDR, 0x3e, in thcv244_thcv241_init()
745 ret |= thine_write_reg(thcv244->client, THCV244_ADDR, 0x1600, in thcv244_thcv241_init()
753 static int thcv244_thcv241_reset_initial(struct thcv244 *thcv244) in thcv244_thcv241_reset_initial() argument
755 struct device *dev = &thcv244->client->dev; in thcv244_thcv241_reset_initial()
758 ret = thcv244_write_array(thcv244->client, thcv244_reset_init_table); in thcv244_thcv241_reset_initial()
760 ret |= thcv241_write_array(thcv244->client, thcv241_reset_init_table0); in thcv244_thcv241_reset_initial()
761 ret |= thine_write_reg(thcv244->client, THCV244_ADDR, 0x0032, in thcv244_thcv241_reset_initial()
763 ret |= thine_write_reg(thcv244->client, THCV241_ADDR, 0x00fe, in thcv244_thcv241_reset_initial()
765 ret |= thine_write_reg(thcv244->client, THCV244_ADDR, 0x0032, in thcv244_thcv241_reset_initial()
767 ret |= thcv241_write_array(thcv244->client, thcv241_reset_init_table1); in thcv244_thcv241_reset_initial()
775 static int __thcv244_start_stream(struct thcv244 *thcv244) in __thcv244_start_stream() argument
779 ret = thcv244_thcv241_reset_initial(thcv244); in __thcv244_start_stream()
781 ret |= thcv244_thcv241_init(thcv244); in __thcv244_start_stream()
786 mutex_unlock(&thcv244->mutex); in __thcv244_start_stream()
787 ret = v4l2_ctrl_handler_setup(&thcv244->ctrl_handler); in __thcv244_start_stream()
788 mutex_lock(&thcv244->mutex); in __thcv244_start_stream()
792 return thine_write_reg(thcv244->client, THCV244_ADDR, in __thcv244_start_stream()
798 static int __thcv244_stop_stream(struct thcv244 *thcv244) in __thcv244_stop_stream() argument
800 return thine_write_reg(thcv244->client, THCV244_ADDR, in __thcv244_stop_stream()
808 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_s_stream() local
809 struct i2c_client *client = thcv244->client; in thcv244_s_stream()
813 thcv244->cur_mode->width, in thcv244_s_stream()
814 thcv244->cur_mode->height, in thcv244_s_stream()
815 DIV_ROUND_CLOSEST(thcv244->cur_mode->max_fps.denominator, in thcv244_s_stream()
816 thcv244->cur_mode->max_fps.numerator)); in thcv244_s_stream()
818 mutex_lock(&thcv244->mutex); in thcv244_s_stream()
820 if (on == thcv244->streaming) in thcv244_s_stream()
830 ret = __thcv244_start_stream(thcv244); in thcv244_s_stream()
837 __thcv244_stop_stream(thcv244); in thcv244_s_stream()
841 thcv244->streaming = on; in thcv244_s_stream()
844 mutex_unlock(&thcv244->mutex); in thcv244_s_stream()
851 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_s_power() local
852 struct i2c_client *client = thcv244->client; in thcv244_s_power()
855 mutex_lock(&thcv244->mutex); in thcv244_s_power()
858 if (thcv244->power_on == !!on) in thcv244_s_power()
868 thcv244->power_on = true; in thcv244_s_power()
871 thcv244->power_on = false; in thcv244_s_power()
875 mutex_unlock(&thcv244->mutex); in thcv244_s_power()
886 static int __thcv244_power_on(struct thcv244 *thcv244) in __thcv244_power_on() argument
890 struct device *dev = &thcv244->client->dev; in __thcv244_power_on()
892 if (!IS_ERR(thcv244->power_gpio)) in __thcv244_power_on()
893 gpiod_set_value_cansleep(thcv244->power_gpio, 1); in __thcv244_power_on()
897 if (!IS_ERR_OR_NULL(thcv244->pins_default)) { in __thcv244_power_on()
898 ret = pinctrl_select_state(thcv244->pinctrl, in __thcv244_power_on()
899 thcv244->pins_default); in __thcv244_power_on()
904 if (!IS_ERR(thcv244->reset_gpio)) in __thcv244_power_on()
905 gpiod_set_value_cansleep(thcv244->reset_gpio, 0); in __thcv244_power_on()
907 ret = regulator_bulk_enable(THCV244_NUM_SUPPLIES, thcv244->supplies); in __thcv244_power_on()
913 if (!IS_ERR(thcv244->reset_gpio)) in __thcv244_power_on()
914 gpiod_set_value_cansleep(thcv244->reset_gpio, 1); in __thcv244_power_on()
917 if (!IS_ERR(thcv244->pwdn_gpio)) in __thcv244_power_on()
918 gpiod_set_value_cansleep(thcv244->pwdn_gpio, 1); in __thcv244_power_on()
927 clk_disable_unprepare(thcv244->xvclk); in __thcv244_power_on()
932 static void __thcv244_power_off(struct thcv244 *thcv244) in __thcv244_power_off() argument
935 struct device *dev = &thcv244->client->dev; in __thcv244_power_off()
937 if (!IS_ERR(thcv244->pwdn_gpio)) in __thcv244_power_off()
938 gpiod_set_value_cansleep(thcv244->pwdn_gpio, 0); in __thcv244_power_off()
939 clk_disable_unprepare(thcv244->xvclk); in __thcv244_power_off()
940 if (!IS_ERR(thcv244->reset_gpio)) in __thcv244_power_off()
941 gpiod_set_value_cansleep(thcv244->reset_gpio, 0); in __thcv244_power_off()
943 if (!IS_ERR_OR_NULL(thcv244->pins_sleep)) { in __thcv244_power_off()
944 ret = pinctrl_select_state(thcv244->pinctrl, in __thcv244_power_off()
945 thcv244->pins_sleep); in __thcv244_power_off()
949 if (!IS_ERR(thcv244->power_gpio)) in __thcv244_power_off()
950 gpiod_set_value_cansleep(thcv244->power_gpio, 0); in __thcv244_power_off()
952 regulator_bulk_disable(THCV244_NUM_SUPPLIES, thcv244->supplies); in __thcv244_power_off()
959 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_runtime_resume() local
961 return __thcv244_power_on(thcv244); in thcv244_runtime_resume()
968 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_runtime_suspend() local
970 __thcv244_power_off(thcv244); in thcv244_runtime_suspend()
978 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_open() local
983 mutex_lock(&thcv244->mutex); in thcv244_open()
990 mutex_unlock(&thcv244->mutex); in thcv244_open()
1016 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_g_mbus_config() local
1017 u32 lane_num = thcv244->bus_cfg.bus.mipi_csi2.num_data_lanes; in thcv244_g_mbus_config()
1031 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_get_selection() local
1035 sel->r.width = thcv244->cur_mode->width; in thcv244_get_selection()
1037 sel->r.height = thcv244->cur_mode->height; in thcv244_get_selection()
1084 static int thcv244_initialize_controls(struct thcv244 *thcv244) in thcv244_initialize_controls() argument
1090 handler = &thcv244->ctrl_handler; in thcv244_initialize_controls()
1091 mode = thcv244->cur_mode; in thcv244_initialize_controls()
1095 handler->lock = &thcv244->mutex; in thcv244_initialize_controls()
1097 thcv244->link_freq = v4l2_ctrl_new_int_menu(handler, NULL, in thcv244_initialize_controls()
1101 thcv244->pixel_rate = v4l2_ctrl_new_std(handler, NULL, in thcv244_initialize_controls()
1106 __v4l2_ctrl_s_ctrl(thcv244->link_freq, in thcv244_initialize_controls()
1111 dev_err(&thcv244->client->dev, in thcv244_initialize_controls()
1116 thcv244->subdev.ctrl_handler = handler; in thcv244_initialize_controls()
1126 static int thcv244_check_sensor_id(struct thcv244 *thcv244, in thcv244_check_sensor_id() argument
1132 static int thcv244_configure_regulators(struct thcv244 *thcv244) in thcv244_configure_regulators() argument
1137 thcv244->supplies[i].supply = thcv244_supply_names[i]; in thcv244_configure_regulators()
1139 return devm_regulator_bulk_get(&thcv244->client->dev, in thcv244_configure_regulators()
1141 thcv244->supplies); in thcv244_configure_regulators()
1149 struct thcv244 *thcv244; in thcv244_probe() local
1160 thcv244 = devm_kzalloc(dev, sizeof(*thcv244), GFP_KERNEL); in thcv244_probe()
1161 if (!thcv244) in thcv244_probe()
1165 &thcv244->module_index); in thcv244_probe()
1167 &thcv244->module_facing); in thcv244_probe()
1169 &thcv244->module_name); in thcv244_probe()
1171 &thcv244->len_name); in thcv244_probe()
1177 thcv244->client = client; in thcv244_probe()
1184 &thcv244->bus_cfg); in thcv244_probe()
1190 thcv244->cur_mode = &supported_modes[0]; in thcv244_probe()
1192 thcv244->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in thcv244_probe()
1193 if (IS_ERR(thcv244->power_gpio)) in thcv244_probe()
1196 thcv244->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in thcv244_probe()
1197 if (IS_ERR(thcv244->reset_gpio)) in thcv244_probe()
1200 thcv244->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in thcv244_probe()
1201 if (IS_ERR(thcv244->pwdn_gpio)) in thcv244_probe()
1204 ret = thcv244_configure_regulators(thcv244); in thcv244_probe()
1210 thcv244->pinctrl = devm_pinctrl_get(dev); in thcv244_probe()
1211 if (!IS_ERR(thcv244->pinctrl)) { in thcv244_probe()
1212 thcv244->pins_default = in thcv244_probe()
1213 pinctrl_lookup_state(thcv244->pinctrl, in thcv244_probe()
1215 if (IS_ERR(thcv244->pins_default)) in thcv244_probe()
1218 thcv244->pins_sleep = in thcv244_probe()
1219 pinctrl_lookup_state(thcv244->pinctrl, in thcv244_probe()
1221 if (IS_ERR(thcv244->pins_sleep)) in thcv244_probe()
1225 mutex_init(&thcv244->mutex); in thcv244_probe()
1227 sd = &thcv244->subdev; in thcv244_probe()
1229 ret = thcv244_initialize_controls(thcv244); in thcv244_probe()
1233 ret = __thcv244_power_on(thcv244); in thcv244_probe()
1237 ret = thcv244_check_sensor_id(thcv244, client); in thcv244_probe()
1246 thcv244->pad.flags = MEDIA_PAD_FL_SOURCE; in thcv244_probe()
1248 ret = media_entity_pads_init(&sd->entity, 1, &thcv244->pad); in thcv244_probe()
1254 if (strcmp(thcv244->module_facing, "back") == 0) in thcv244_probe()
1260 thcv244->module_index, facing, in thcv244_probe()
1279 __thcv244_power_off(thcv244); in thcv244_probe()
1281 v4l2_ctrl_handler_free(&thcv244->ctrl_handler); in thcv244_probe()
1283 mutex_destroy(&thcv244->mutex); in thcv244_probe()
1291 struct thcv244 *thcv244 = to_thcv244(sd); in thcv244_remove() local
1297 v4l2_ctrl_handler_free(&thcv244->ctrl_handler); in thcv244_remove()
1298 mutex_destroy(&thcv244->mutex); in thcv244_remove()
1302 __thcv244_power_off(thcv244); in thcv244_remove()