Lines Matching refs:gc2355
110 struct gc2355 { struct
139 #define to_gc2355(sd) container_of(sd, struct gc2355, subdev) argument
427 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_set_fmt() local
431 mutex_lock(&gc2355->mutex); in gc2355_set_fmt()
442 mutex_unlock(&gc2355->mutex); in gc2355_set_fmt()
446 gc2355->cur_mode = mode; in gc2355_set_fmt()
448 __v4l2_ctrl_modify_range(gc2355->hblank, h_blank, in gc2355_set_fmt()
451 __v4l2_ctrl_modify_range(gc2355->vblank, vblank_def, in gc2355_set_fmt()
456 mutex_unlock(&gc2355->mutex); in gc2355_set_fmt()
465 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_get_fmt() local
466 const struct gc2355_mode *mode = gc2355->cur_mode; in gc2355_get_fmt()
468 mutex_lock(&gc2355->mutex); in gc2355_get_fmt()
473 mutex_unlock(&gc2355->mutex); in gc2355_get_fmt()
482 mutex_unlock(&gc2355->mutex); in gc2355_get_fmt()
519 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_g_frame_interval() local
520 const struct gc2355_mode *mode = gc2355->cur_mode; in gc2355_g_frame_interval()
527 static void gc2355_get_module_inf(struct gc2355 *gc2355, in gc2355_get_module_inf() argument
532 strlcpy(inf->base.module, gc2355->module_name, in gc2355_get_module_inf()
534 strlcpy(inf->base.lens, gc2355->len_name, sizeof(inf->base.lens)); in gc2355_get_module_inf()
539 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_ioctl() local
545 gc2355_get_module_inf(gc2355, (struct rkmodule_inf *)arg); in gc2355_ioctl()
552 ret = gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x03); in gc2355_ioctl()
553 ret |= gc2355_write_reg(gc2355->client, GC2355_MODE_SELECT, in gc2355_ioctl()
555 ret |= gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x00); in gc2355_ioctl()
557 ret = gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x03); in gc2355_ioctl()
558 ret |= gc2355_write_reg(gc2355->client, GC2355_MODE_SELECT, in gc2355_ioctl()
560 ret |= gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x00); in gc2355_ioctl()
620 static int __gc2355_start_stream(struct gc2355 *gc2355) in __gc2355_start_stream() argument
624 ret = gc2355_write_array(gc2355->client, gc2355_global_regs); in __gc2355_start_stream()
628 ret = gc2355_write_array(gc2355->client, gc2355->cur_mode->reg_list); in __gc2355_start_stream()
633 mutex_unlock(&gc2355->mutex); in __gc2355_start_stream()
634 ret = v4l2_ctrl_handler_setup(&gc2355->ctrl_handler); in __gc2355_start_stream()
635 mutex_lock(&gc2355->mutex); in __gc2355_start_stream()
639 ret = gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x03); in __gc2355_start_stream()
640 ret = gc2355_write_reg(gc2355->client, GC2355_MODE_SELECT, in __gc2355_start_stream()
642 ret = gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x00); in __gc2355_start_stream()
646 static int __gc2355_stop_stream(struct gc2355 *gc2355) in __gc2355_stop_stream() argument
650 ret = gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x03); in __gc2355_stop_stream()
651 ret = gc2355_write_reg(gc2355->client, GC2355_MODE_SELECT, in __gc2355_stop_stream()
653 ret = gc2355_write_reg(gc2355->client, GC2355_PAGE_SELECT, 0x00); in __gc2355_stop_stream()
659 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_s_stream() local
660 struct i2c_client *client = gc2355->client; in gc2355_s_stream()
663 mutex_lock(&gc2355->mutex); in gc2355_s_stream()
665 if (on == gc2355->streaming) in gc2355_s_stream()
675 ret = __gc2355_start_stream(gc2355); in gc2355_s_stream()
682 __gc2355_stop_stream(gc2355); in gc2355_s_stream()
686 gc2355->streaming = on; in gc2355_s_stream()
689 mutex_unlock(&gc2355->mutex); in gc2355_s_stream()
700 static int __gc2355_power_on(struct gc2355 *gc2355) in __gc2355_power_on() argument
704 struct device *dev = &gc2355->client->dev; in __gc2355_power_on()
706 if (!IS_ERR_OR_NULL(gc2355->pins_default)) { in __gc2355_power_on()
707 ret = pinctrl_select_state(gc2355->pinctrl, in __gc2355_power_on()
708 gc2355->pins_default); in __gc2355_power_on()
712 ret = clk_set_rate(gc2355->xvclk, GC2355_XVCLK_FREQ); in __gc2355_power_on()
715 if (clk_get_rate(gc2355->xvclk) != GC2355_XVCLK_FREQ) in __gc2355_power_on()
717 ret = clk_prepare_enable(gc2355->xvclk); in __gc2355_power_on()
722 if (!IS_ERR(gc2355->reset_gpio)) in __gc2355_power_on()
723 gpiod_set_value_cansleep(gc2355->reset_gpio, 0); in __gc2355_power_on()
725 ret = regulator_bulk_enable(GC2355_NUM_SUPPLIES, gc2355->supplies); in __gc2355_power_on()
731 if (!IS_ERR(gc2355->reset_gpio)) in __gc2355_power_on()
732 gpiod_set_value_cansleep(gc2355->reset_gpio, 1); in __gc2355_power_on()
735 if (!IS_ERR(gc2355->pwdn_gpio)) in __gc2355_power_on()
736 gpiod_set_value_cansleep(gc2355->pwdn_gpio, 1); in __gc2355_power_on()
745 clk_disable_unprepare(gc2355->xvclk); in __gc2355_power_on()
750 static void __gc2355_power_off(struct gc2355 *gc2355) in __gc2355_power_off() argument
753 struct device *dev = &gc2355->client->dev; in __gc2355_power_off()
755 if (!IS_ERR(gc2355->pwdn_gpio)) in __gc2355_power_off()
756 gpiod_set_value_cansleep(gc2355->pwdn_gpio, 0); in __gc2355_power_off()
757 clk_disable_unprepare(gc2355->xvclk); in __gc2355_power_off()
758 if (!IS_ERR(gc2355->reset_gpio)) in __gc2355_power_off()
759 gpiod_set_value_cansleep(gc2355->reset_gpio, 0); in __gc2355_power_off()
760 if (!IS_ERR_OR_NULL(gc2355->pins_sleep)) { in __gc2355_power_off()
761 ret = pinctrl_select_state(gc2355->pinctrl, in __gc2355_power_off()
762 gc2355->pins_sleep); in __gc2355_power_off()
766 regulator_bulk_disable(GC2355_NUM_SUPPLIES, gc2355->supplies); in __gc2355_power_off()
773 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_runtime_resume() local
775 return __gc2355_power_on(gc2355); in gc2355_runtime_resume()
782 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_runtime_suspend() local
784 __gc2355_power_off(gc2355); in gc2355_runtime_suspend()
792 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_open() local
797 mutex_lock(&gc2355->mutex); in gc2355_open()
804 mutex_unlock(&gc2355->mutex); in gc2355_open()
879 struct gc2355 *gc2355 = container_of(ctrl->handler, in gc2355_set_ctrl() local
880 struct gc2355, ctrl_handler); in gc2355_set_ctrl()
881 struct i2c_client *client = gc2355->client; in gc2355_set_ctrl()
890 max = gc2355->cur_mode->height + ctrl->val - 4; in gc2355_set_ctrl()
891 __v4l2_ctrl_modify_range(gc2355->exposure, in gc2355_set_ctrl()
892 gc2355->exposure->minimum, max, in gc2355_set_ctrl()
893 gc2355->exposure->step, in gc2355_set_ctrl()
894 gc2355->exposure->default_value); in gc2355_set_ctrl()
904 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
907 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
910 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
916 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
921 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
925 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
928 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
933 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
937 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
940 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
945 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
949 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
952 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
956 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
960 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
963 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
969 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
972 ret = gc2355_write_reg(gc2355->client, in gc2355_set_ctrl()
974 ((ctrl->val + gc2355->cur_mode->height) >> 8) & 0x3f); in gc2355_set_ctrl()
975 ret = gc2355_write_reg(gc2355->client, GC2355_REG_VTS_L, in gc2355_set_ctrl()
976 (ctrl->val + gc2355->cur_mode->height) & in gc2355_set_ctrl()
995 static int gc2355_initialize_controls(struct gc2355 *gc2355) in gc2355_initialize_controls() argument
1003 struct device *dev = &gc2355->client->dev; in gc2355_initialize_controls()
1006 handler = &gc2355->ctrl_handler; in gc2355_initialize_controls()
1007 mode = gc2355->cur_mode; in gc2355_initialize_controls()
1011 handler->lock = &gc2355->mutex; in gc2355_initialize_controls()
1022 gc2355->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in gc2355_initialize_controls()
1024 if (gc2355->hblank) in gc2355_initialize_controls()
1025 gc2355->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in gc2355_initialize_controls()
1028 gc2355->vblank = v4l2_ctrl_new_std(handler, &gc2355_ctrl_ops, in gc2355_initialize_controls()
1034 gc2355->exposure = v4l2_ctrl_new_std(handler, &gc2355_ctrl_ops, in gc2355_initialize_controls()
1039 gc2355->anal_gain = v4l2_ctrl_new_std(handler, &gc2355_ctrl_ops, in gc2355_initialize_controls()
1046 dev_err(&gc2355->client->dev, in gc2355_initialize_controls()
1051 gc2355->subdev.ctrl_handler = handler; in gc2355_initialize_controls()
1061 static int gc2355_check_sensor_id(struct gc2355 *gc2355, in gc2355_check_sensor_id() argument
1064 struct device *dev = &gc2355->client->dev; in gc2355_check_sensor_id()
1092 static int gc2355_configure_regulators(struct gc2355 *gc2355) in gc2355_configure_regulators() argument
1097 gc2355->supplies[i].supply = gc2355_supply_names[i]; in gc2355_configure_regulators()
1099 return devm_regulator_bulk_get(&gc2355->client->dev, in gc2355_configure_regulators()
1101 gc2355->supplies); in gc2355_configure_regulators()
1109 struct gc2355 *gc2355; in gc2355_probe() local
1119 gc2355 = devm_kzalloc(dev, sizeof(*gc2355), GFP_KERNEL); in gc2355_probe()
1120 if (!gc2355) in gc2355_probe()
1124 &gc2355->module_index); in gc2355_probe()
1126 &gc2355->module_facing); in gc2355_probe()
1128 &gc2355->module_name); in gc2355_probe()
1130 &gc2355->len_name); in gc2355_probe()
1136 gc2355->client = client; in gc2355_probe()
1137 gc2355->cur_mode = &supported_modes[0]; in gc2355_probe()
1139 gc2355->xvclk = devm_clk_get(dev, "xvclk"); in gc2355_probe()
1140 if (IS_ERR(gc2355->xvclk)) { in gc2355_probe()
1145 gc2355->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in gc2355_probe()
1146 if (IS_ERR(gc2355->reset_gpio)) in gc2355_probe()
1149 gc2355->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc2355_probe()
1150 if (IS_ERR(gc2355->pwdn_gpio)) in gc2355_probe()
1153 gc2355->pinctrl = devm_pinctrl_get(dev); in gc2355_probe()
1154 if (!IS_ERR(gc2355->pinctrl)) { in gc2355_probe()
1155 gc2355->pins_default = in gc2355_probe()
1156 pinctrl_lookup_state(gc2355->pinctrl, in gc2355_probe()
1158 if (IS_ERR(gc2355->pins_default)) in gc2355_probe()
1161 gc2355->pins_sleep = in gc2355_probe()
1162 pinctrl_lookup_state(gc2355->pinctrl, in gc2355_probe()
1164 if (IS_ERR(gc2355->pins_sleep)) in gc2355_probe()
1170 ret = gc2355_configure_regulators(gc2355); in gc2355_probe()
1176 mutex_init(&gc2355->mutex); in gc2355_probe()
1178 sd = &gc2355->subdev; in gc2355_probe()
1180 ret = gc2355_initialize_controls(gc2355); in gc2355_probe()
1184 ret = __gc2355_power_on(gc2355); in gc2355_probe()
1188 ret = gc2355_check_sensor_id(gc2355, client); in gc2355_probe()
1198 gc2355->pad.flags = MEDIA_PAD_FL_SOURCE; in gc2355_probe()
1200 ret = media_entity_pads_init(&sd->entity, 1, &gc2355->pad); in gc2355_probe()
1206 if (strcmp(gc2355->module_facing, "back") == 0) in gc2355_probe()
1212 gc2355->module_index, facing, in gc2355_probe()
1231 __gc2355_power_off(gc2355); in gc2355_probe()
1233 v4l2_ctrl_handler_free(&gc2355->ctrl_handler); in gc2355_probe()
1235 mutex_destroy(&gc2355->mutex); in gc2355_probe()
1243 struct gc2355 *gc2355 = to_gc2355(sd); in gc2355_remove() local
1249 v4l2_ctrl_handler_free(&gc2355->ctrl_handler); in gc2355_remove()
1250 mutex_destroy(&gc2355->mutex); in gc2355_remove()
1254 __gc2355_power_off(gc2355); in gc2355_remove()