Lines Matching refs:gc0312
94 struct gc0312 { struct
479 static inline struct gc0312 *to_gc0312(struct v4l2_subdev *sd) in to_gc0312()
481 return container_of(sd, struct gc0312, sd); in to_gc0312()
568 static void gc0312_set_streaming(struct gc0312 *gc0312, int on) in gc0312_set_streaming() argument
570 struct i2c_client *client = gc0312->client; in gc0312_set_streaming()
631 struct gc0312 *gc0312 = to_gc0312(sd); in gc0312_get_fmt() local
640 mutex_lock(&gc0312->lock); in gc0312_get_fmt()
642 mutex_unlock(&gc0312->lock); in gc0312_get_fmt()
649 mutex_lock(&gc0312->lock); in gc0312_get_fmt()
650 fmt->format = gc0312->format; in gc0312_get_fmt()
651 mutex_unlock(&gc0312->lock); in gc0312_get_fmt()
654 gc0312->format.code, gc0312->format.width, in gc0312_get_fmt()
655 gc0312->format.height); in gc0312_get_fmt()
696 struct gc0312 *gc0312 = to_gc0312(sd); in gc0312_set_fmt() local
714 mutex_lock(&gc0312->lock); in gc0312_set_fmt()
724 if (gc0312->streaming) { in gc0312_set_fmt()
725 mutex_unlock(&gc0312->lock); in gc0312_set_fmt()
729 gc0312->frame_size = size; in gc0312_set_fmt()
730 gc0312->format = fmt->format; in gc0312_set_fmt()
733 mutex_unlock(&gc0312->lock); in gc0312_set_fmt()
737 static void gc0312_get_module_inf(struct gc0312 *gc0312, in gc0312_get_module_inf() argument
742 strlcpy(inf->base.module, gc0312->module_name, in gc0312_get_module_inf()
744 strlcpy(inf->base.lens, gc0312->len_name, sizeof(inf->base.lens)); in gc0312_get_module_inf()
749 struct gc0312 *gc0312 = to_gc0312(sd); in gc0312_ioctl() local
755 gc0312_get_module_inf(gc0312, (struct rkmodule_inf *)arg); in gc0312_ioctl()
762 gc0312_set_streaming(gc0312, 0xff); in gc0312_ioctl()
764 gc0312_set_streaming(gc0312, 0x00); in gc0312_ioctl()
826 struct gc0312 *gc0312 = to_gc0312(sd); in gc0312_s_stream() local
831 mutex_lock(&gc0312->lock); in gc0312_s_stream()
835 if (gc0312->streaming == on) in gc0312_s_stream()
840 gc0312_set_streaming(gc0312, 0x00); in gc0312_s_stream()
841 gc0312->streaming = on; in gc0312_s_stream()
842 if (!IS_ERR(gc0312->pwdn_gpio)) { in gc0312_s_stream()
843 gpiod_set_value_cansleep(gc0312->pwdn_gpio, 1); in gc0312_s_stream()
849 if (!IS_ERR(gc0312->pwdn_gpio)) { in gc0312_s_stream()
850 gpiod_set_value_cansleep(gc0312->pwdn_gpio, 0); in gc0312_s_stream()
854 ret = gc0312_write_array(client, gc0312->frame_size->regs); in gc0312_s_stream()
858 gc0312_set_streaming(gc0312, 0xFF); in gc0312_s_stream()
859 gc0312->streaming = on; in gc0312_s_stream()
862 mutex_unlock(&gc0312->lock); in gc0312_s_stream()
866 static int gc0312_set_test_pattern(struct gc0312 *gc0312, int value) in gc0312_set_test_pattern() argument
873 struct gc0312 *gc0312 = in gc0312_s_ctrl() local
874 container_of(ctrl->handler, struct gc0312, ctrls); in gc0312_s_ctrl()
878 return gc0312_set_test_pattern(gc0312, ctrl->val); in gc0312_s_ctrl()
972 static int gc0312_detect(struct gc0312 *gc0312) in gc0312_detect() argument
974 struct i2c_client *client = gc0312->client; in gc0312_detect()
996 if (!IS_ERR(gc0312->pwdn_gpio)) in gc0312_detect()
997 gpiod_set_value_cansleep(gc0312->pwdn_gpio, 1); in gc0312_detect()
1004 static int __gc0312_power_on(struct gc0312 *gc0312) in __gc0312_power_on() argument
1007 struct device *dev = &gc0312->client->dev; in __gc0312_power_on()
1009 if (!IS_ERR(gc0312->xvclk)) { in __gc0312_power_on()
1010 ret = clk_set_rate(gc0312->xvclk, 24000000); in __gc0312_power_on()
1015 if (!IS_ERR(gc0312->pwdn_gpio)) { in __gc0312_power_on()
1016 gpiod_set_value_cansleep(gc0312->pwdn_gpio, 1); in __gc0312_power_on()
1020 if (!IS_ERR(gc0312->supplies)) { in __gc0312_power_on()
1022 gc0312->supplies); in __gc0312_power_on()
1029 if (!IS_ERR(gc0312->pwdn_gpio)) { in __gc0312_power_on()
1030 gpiod_set_value_cansleep(gc0312->pwdn_gpio, 0); in __gc0312_power_on()
1034 if (!IS_ERR(gc0312->xvclk)) { in __gc0312_power_on()
1035 ret = clk_prepare_enable(gc0312->xvclk); in __gc0312_power_on()
1045 static void __gc0312_power_off(struct gc0312 *gc0312) in __gc0312_power_off() argument
1047 if (!IS_ERR(gc0312->xvclk)) in __gc0312_power_off()
1048 clk_disable_unprepare(gc0312->xvclk); in __gc0312_power_off()
1049 if (!IS_ERR(gc0312->supplies)) in __gc0312_power_off()
1050 regulator_bulk_disable(GC0312_NUM_SUPPLIES, gc0312->supplies); in __gc0312_power_off()
1051 if (!IS_ERR(gc0312->pwdn_gpio)) in __gc0312_power_off()
1052 gpiod_set_value_cansleep(gc0312->pwdn_gpio, 1); in __gc0312_power_off()
1055 static int gc0312_configure_regulators(struct gc0312 *gc0312) in gc0312_configure_regulators() argument
1060 gc0312->supplies[i].supply = gc0312_supply_names[i]; in gc0312_configure_regulators()
1062 return devm_regulator_bulk_get(&gc0312->client->dev, in gc0312_configure_regulators()
1064 gc0312->supplies); in gc0312_configure_regulators()
1067 static int gc0312_parse_of(struct gc0312 *gc0312) in gc0312_parse_of() argument
1069 struct device *dev = &gc0312->client->dev; in gc0312_parse_of()
1072 gc0312->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc0312_parse_of()
1073 if (IS_ERR(gc0312->pwdn_gpio)) in gc0312_parse_of()
1076 ret = gc0312_configure_regulators(gc0312); in gc0312_parse_of()
1080 return __gc0312_power_on(gc0312); in gc0312_parse_of()
1089 struct gc0312 *gc0312; in gc0312_probe() local
1098 gc0312 = devm_kzalloc(&client->dev, sizeof(*gc0312), GFP_KERNEL); in gc0312_probe()
1099 if (!gc0312) in gc0312_probe()
1103 &gc0312->module_index); in gc0312_probe()
1105 &gc0312->module_facing); in gc0312_probe()
1107 &gc0312->module_name); in gc0312_probe()
1109 &gc0312->len_name); in gc0312_probe()
1115 gc0312->client = client; in gc0312_probe()
1116 gc0312->xvclk = devm_clk_get(&client->dev, "xvclk"); in gc0312_probe()
1117 if (IS_ERR(gc0312->xvclk)) { in gc0312_probe()
1122 gc0312_parse_of(gc0312); in gc0312_probe()
1124 gc0312->xvclk_frequency = clk_get_rate(gc0312->xvclk); in gc0312_probe()
1125 if (gc0312->xvclk_frequency < 6000000 || in gc0312_probe()
1126 gc0312->xvclk_frequency > 27000000) in gc0312_probe()
1129 v4l2_ctrl_handler_init(&gc0312->ctrls, 2); in gc0312_probe()
1130 gc0312->link_frequency = in gc0312_probe()
1131 v4l2_ctrl_new_std(&gc0312->ctrls, &gc0312_ctrl_ops, in gc0312_probe()
1136 v4l2_ctrl_new_std_menu_items(&gc0312->ctrls, &gc0312_ctrl_ops, in gc0312_probe()
1140 gc0312->sd.ctrl_handler = &gc0312->ctrls; in gc0312_probe()
1142 if (gc0312->ctrls.error) { in gc0312_probe()
1144 __func__, gc0312->ctrls.error); in gc0312_probe()
1145 return gc0312->ctrls.error; in gc0312_probe()
1148 sd = &gc0312->sd; in gc0312_probe()
1159 gc0312->pad.flags = MEDIA_PAD_FL_SOURCE; in gc0312_probe()
1161 ret = media_entity_pads_init(&sd->entity, 1, &gc0312->pad); in gc0312_probe()
1163 v4l2_ctrl_handler_free(&gc0312->ctrls); in gc0312_probe()
1168 mutex_init(&gc0312->lock); in gc0312_probe()
1170 gc0312_get_default_format(&gc0312->format); in gc0312_probe()
1171 gc0312->frame_size = &gc0312_framesizes[0]; in gc0312_probe()
1173 ret = gc0312_detect(gc0312); in gc0312_probe()
1178 if (strcmp(gc0312->module_facing, "back") == 0) in gc0312_probe()
1184 gc0312->module_index, facing, in gc0312_probe()
1195 v4l2_ctrl_handler_free(&gc0312->ctrls); in gc0312_probe()
1199 mutex_destroy(&gc0312->lock); in gc0312_probe()
1200 __gc0312_power_off(gc0312); in gc0312_probe()
1207 struct gc0312 *gc0312 = to_gc0312(sd); in gc0312_remove() local
1209 v4l2_ctrl_handler_free(&gc0312->ctrls); in gc0312_remove()
1214 mutex_destroy(&gc0312->lock); in gc0312_remove()
1216 __gc0312_power_off(gc0312); in gc0312_remove()